Skip to content

Commit

Permalink
fix bug with email auth
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed May 20, 2024
1 parent dbdc80e commit 792d9c6
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import useFeedback from '@features/app_start/shared/hooks/useFeedback';
import { useAppTranslation } from '@hooks/index';
import { getMessageByCode } from '@services/i18n/translation';
import { NextStepType } from './index.types';
import { UserLoginResponseType } from '@definition/api';
import { dbAppSettingsUpdate } from '@services/dexie/settings';

const useEmailLinkAuth = () => {
const { t } = useAppTranslation();
Expand All @@ -35,11 +37,18 @@ const useEmailLinkAuth = () => {
setSearchParams('');
};

const handleResult = async (result: NextStepType) => {
const handleResult = async (data: UserLoginResponseType, result: NextStepType) => {
setSearchParams('');
setIsEmailLinkAuthenticate(false);
setIsEmailAuth(false);

await dbAppSettingsUpdate({
'user_settings.account_type': 'vip',
'user_settings.cong_role': data.cong_role,
'user_settings.lastname': data.lastname,
'user_settings.firstname': data.firstname,
});

if (result.encryption) {
setIsEncryptionCodeOpen(true);
} else if (result.isVerifyMFA) {
Expand Down Expand Up @@ -92,7 +101,7 @@ const useEmailLinkAuth = () => {
result.isVerifyMFA = true;
}

await handleResult(result);
await handleResult(data, result);
setIsProcessing(false);
} catch (err) {
await displayOnboardingFeedback({
Expand Down

0 comments on commit 792d9c6

Please sign in to comment.