The credential then will sent to /api/v1/users/check to make sure the credential is correct. If incorrect, server will throw 403 and the login page will shown a "incorrect email/password" error.
Correct credential will be saved into localStorage (like a browser's cookie, but can be accessed via JS).
Every API call from frontend will use credential taken from localStorage. If it doesn't exist or invalid, then users will be redirected to login page again.
Important note
Every react component MUST use BaseDetroitComponent instead of React.Component for automatic initialization of AuthenticationService
ALL API call MUST use apiCall() function instead of other AJAX call (like fetch() or JQuery) so it will automatically use credential/token.
Create login system for frontend:
How login works:
/api/v1/users/check
to make sure the credential is correct. If incorrect, server will throw 403 and the login page will shown a "incorrect email/password" error.Important note
BaseDetroitComponent
instead ofReact.Component
for automatic initialization ofAuthenticationService
apiCall()
function instead of other AJAX call (like fetch() or JQuery) so it will automatically use credential/token.