Skip to content

Commit

Permalink
fix: add notifier for non existent password
Browse files Browse the repository at this point in the history
  • Loading branch information
victorggonzalez committed Mar 28, 2022
1 parent 0ed58de commit bcd10da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/actions/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SIGN_UP_DUPLICATE,
SIGN_IN_PASSWORD_INVALID,
SIGN_IN_PASSWORD_SUCCESS,
SIGN_IN_PASSWORD_NON_EXISTENT,
} from '../types/member';
import notifier from '../utils/notifier';

Expand Down Expand Up @@ -45,6 +46,8 @@ export const signInPassword = async (payload) => {
} catch (error) {
if (error.response.status === StatusCodes.UNAUTHORIZED) {
notifier.error({ code: SIGN_IN_PASSWORD_INVALID, error });
} else if (error.response.status === StatusCodes.NOT_ACCEPTABLE) {
notifier.error({ code: SIGN_IN_PASSWORD_NON_EXISTENT, error });
} else {
notifier.error({ code: SIGN_IN_INVALID, error });
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const SIGN_IN_INVALID_PASSWORD_MESSAGE =
'Incorrect password. Please try again.';
export const SIGN_IN_SUCCESS_PASSWORD_MESSAGE =
'Correct password. You successfully signed in.';
export const SIGN_IN_NON_EXISTENT_PASSWORD_MESSAGE =
'This user does not have a password set. Please use email sign in.';
export const SIGN_UP_ERROR_MESSAGE = 'There was an error signing up.';
export const SIGN_UP_DUPLICATE_MESSAGE =
'This user already exists. Please sign in.';
Expand Down
1 change: 1 addition & 0 deletions src/types/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const SIGN_IN_INVALID = 'SIGN_IN_INVALID';
export const SIGN_IN_ERROR = 'SIGN_IN_ERROR';
export const SIGN_IN_PASSWORD_SUCCESS = 'SIGN_IN_PASSWORD_SUCCESS';
export const SIGN_IN_PASSWORD_INVALID = 'SIGN_IN_PASSWORD_INVALID';
export const SIGN_IN_PASSWORD_NON_EXISTENT = 'SIGN_IN_PASSWORD_NON_EXISTENT';
export const SIGN_IN_PASSWORD_ERROR = 'SIGN_IN_PASSWORD_ERROR';
export const SIGN_UP_DUPLICATE = 'SIGN_UP_DUPLICATE';
export const SIGN_UP_SUCCESS = 'SIGN_UP_SUCCESS';
Expand Down
6 changes: 6 additions & 0 deletions src/utils/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
SIGN_UP_DUPLICATE_MESSAGE,
SIGN_UP_ERROR_MESSAGE,
SIGN_UP_SUCCESS_MESSAGE,
SIGN_IN_NON_EXISTENT_PASSWORD_MESSAGE,
} from '../config/messages';
import {
SIGN_IN_ERROR,
SIGN_IN_INVALID,
SIGN_IN_PASSWORD_INVALID,
SIGN_IN_PASSWORD_NON_EXISTENT,
SIGN_IN_PASSWORD_SUCCESS,
SIGN_IN_SUCCESS,
SIGN_UP_DUPLICATE,
Expand Down Expand Up @@ -42,6 +44,10 @@ const notifier = {
message = SIGN_IN_SUCCESS_PASSWORD_MESSAGE;
break;
}
case SIGN_IN_PASSWORD_NON_EXISTENT: {
message = SIGN_IN_NON_EXISTENT_PASSWORD_MESSAGE;
break;
}
case SIGN_IN_ERROR: {
message = SIGN_IN_ERROR_MESSAGE;
break;
Expand Down

0 comments on commit bcd10da

Please sign in to comment.