Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update authentication.js #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Component/Auth/__action/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import {tokenToHeaders} from "../../../setup/utility/tokenToHeaders";

/**
* authentication
* this method do two action. validation token and get user details and set to redux.
* this method does two actions: validate the token and get the user details and set to redux.
*
* @param token <string>: user authentication key. like "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...."
* @returns {Promise<any>}: when user is valid do then and when invalid do catch
* @returns {Promise<any>}: when user is valid, do then and when it is invalid, do catch
*/
export const authentication = (token) => {
return axios({
url: api.userDetails,
token: tokenToHeaders({}, token)
})
.then((response) => {
// token is valid and user details ready to use
// token is valid and user details are ready to use
setStore({
localUser: {
updated: true,
Expand All @@ -29,7 +29,7 @@ export const authentication = (token) => {
});
})
.catch((e) => {
// token is invalid or occur an error
// token is invalid or an error occured
signingOut();
toast.error('authentication error. please log in again.');
console.error(e);
Expand Down