Skip to content

Commit

Permalink
[Fix]: invalid code error fix (#2215)
Browse files Browse the repository at this point in the history
* feat(Auth): invalid code error fix

* feat(Auth): invalid code error fix

* feat(Auth): invalid code error fix

* Update useAuthenticationPasscode.ts

---------

Co-authored-by: Ruslan K <evereq@gmail.com>
  • Loading branch information
Anishali2 and evereq authored Feb 16, 2024
1 parent fe46f2c commit fdea8d7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions apps/web/app/hooks/auth/useAuthenticationPasscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ export function useAuthenticationPasscode() {
const verifySignInEmailConfirmRequest = async ({ email, code }: { email: string; code: string }) => {
signInEmailConfirmQueryCall(email, code)
.then((res) => {
const checkError: {
message: string;
} = res.data as any;
const isError = checkError.message === 'Unauthorized';
if (isError) {
setErrors({
code: 'Invalid code. Please try again.'
});
} else {
setErrors({});
}
const data = res.data as ISigninEmailConfirmResponse;
if (!data.workspaces) {
return;
Expand Down Expand Up @@ -166,12 +177,10 @@ export function useAuthenticationPasscode() {
e.preventDefault();
setErrors({});
const { errors, valid } = authFormValidate(['email', 'code'], formValues as any);

if (!valid) {
setErrors(errors);
return;
}

infiniteLoading.current = true;

verifySignInEmailConfirmRequest({
Expand Down

0 comments on commit fdea8d7

Please sign in to comment.