WordPress Admin settings.
Install Simple JWT WP plugin and set the configurations required listed below.
In the Simple JWT plugin open the “General” tab:
- Setup “Route Namespace” with the same format “namespace/” (any unique string end with ‘\’).
- Under Decryption key source select ‘Plugin Settings’
- Under JWT Decrypt Algorithm select ‘HS256’
- For JWT Decryption Key enter the unique string.
- For Get JWT token from setup “REQUEST = JWT” and select ‘On’ for connected dropdown.
Open the “Login” tab
- Toggle Allow Auto-Login to ‘YES’
- Toggle Auto-Login Requires Auth Code to ‘NO’
- Under JWT Login Settings select ‘Log in by WordPress Username’ and configure the username in the next input field.
- Then setup the redirect page after Auto-Login.
In “Register Users” Tab
- Toggle “Allow Register” to ‘YES’
- Toggle “Register Requires Auth Code” to ‘NO’
- Setup “New User profile slug” from any of given below as default.
- Check the “Return a JWT in the response” checkbox.
- Under “Allowed user_meta keys on create user” enter ‘phone’ in input field.
In the “Authentication” tab
- Toggle “Allow Authentication” to ‘Yes’
- Toggle “Authentication Requires Auth Code” to ‘No’
- Select all checkboxes under the “JWT Payload parameters”
- Add “JWT time to live”
- Configure the “Refresh time to live”
- And save the setting from top right corner button.
- Configure “Main URL” the base URL of WordPress Site.
- Configure “Simple JWT Plugin Namespace” same as configured in WordPress site earlier.
- Select Registration Type.
- Add heading to display on login page.
- Set text and banner colors.
- Save and you are good to go.
Functionality in the app
In order to access the feature from the app, the user must first register or log into the app, otherwise the message “You must be signed in to use this feature” is displayed.
The following scenarios occur the first time you access the feature.
a) The user is NOT registered on the WP site:
If the “MANDATORY REGISTRATION TO THE WEBSITE” option is selected in the module settings:
A form is displayed to enter User and Password. If not match, a popup appears with “We are sorry but the credentials are not correct or do not exist. Do you want to go to the site registration?”
If yes, the user is redirected to the WP site registration page (you need to fill in the URL of the WP site registration page in the form settings)
If the “APP REGISTRATION” option is selected in the module settings:
User fills in user and password and if it does not exist in WP a user is automatically created on WP SITE.
b) The user is ALREADY registered on the WP site:
the user has to enter e-mail and password only once.