finalized signup/signin ux regarding redirects

This commit is contained in:
Sheen Capadngan
2023-05-07 20:54:30 +08:00
parent ea86e59d4f
commit 4c434555a4
9 changed files with 46 additions and 12 deletions
@@ -33,15 +33,15 @@ export default function PasswordInputStep({
const handleLogin = async () => {
try {
setIsLoading(true);
const isLoginSuccessful = await attemptLogin({
const loginAttempt = await attemptLogin({
email,
password
});
if (isLoginSuccessful && isLoginSuccessful.success) {
if (loginAttempt && loginAttempt.success) {
// case: login was successful
if (isLoginSuccessful.mfaEnabled) {
if (loginAttempt.mfaEnabled) {
// case: login requires MFA step
setStep(2);
setIsLoading(false);
@@ -167,6 +167,7 @@ export default function UserInfoStep({
// unset signup JWT token and set JWT token
SecurityClient.setSignupToken('');
SecurityClient.setToken(response.token);
SecurityClient.setProviderAuthToken('');
saveTokenToLocalStorage({
publicKey,
@@ -91,7 +91,9 @@ const attemptLogin = async (
token
) {
// case: MFA is not enabled
// unset provider auth token in case it was used
SecurityClient.setProviderAuthToken('');
// set JWT token
SecurityClient.setToken(token);
@@ -36,7 +36,10 @@ const attemptLoginMfa = async ({
}, async () => {
try {
const clientPublicKey = client.getPublicKey();
const { salt } = await login1(email, clientPublicKey);
const { salt } = await login1({
email,
clientPublicKey,
});
const {
encryptionVersion,
@@ -56,6 +59,7 @@ const attemptLoginMfa = async ({
// unset temporary (MFA) JWT token and set JWT token
SecurityClient.setMfaToken('');
SecurityClient.setToken(token);
SecurityClient.setProviderAuthToken('');
const privateKey = await KeyService.decryptPrivateKey({
encryptionVersion,