Skip to content

Commit

Permalink
fix(LoginPage): verify 2FA on reset password
Browse files Browse the repository at this point in the history
  • Loading branch information
BreadGenie committed Aug 30, 2024
1 parent cc73e57 commit ba0007c
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions dashboard/src2/pages/LoginSignup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div v-if="!(resetPasswordEmailSent || accountRequestCreated)">
<form class="flex flex-col" @submit.prevent="submitForm">
<!-- Forgot Password Section -->
<template v-if="hasForgotPassword">
<template v-if="hasForgotPassword && !is2FA">
<FormControl
label="Email"
type="email"
Expand Down Expand Up @@ -74,11 +74,16 @@
<Button v-else class="mt-4" variant="solid">
Log in with {{ oauthProviderName }}
</Button>
<ErrorMessage class="mt-2" :message="$session.login.error" />
<ErrorMessage
class="mt-2"
:message="
$session.login.error || $resources.is2FAEnabled.error
"
/>
</template>

<!-- 2FA Section -->
<template v-else-if="isLogin && is2FA">
<template v-else-if="is2FA">
<FormControl
label="2FA Code from your Authenticator App"
placeholder="123456"
Expand Down Expand Up @@ -372,7 +377,13 @@ export default {
return {
url: 'press.api.account.verify_2fa',
onSuccess: async () => {
await this.login();
if (this.isLogin) {
await this.login();
} else if (this.hasForgotPassword) {
await this.$resources.resetPassword.submit({
email: this.email
});
}
}
};
}
Expand Down Expand Up @@ -404,7 +415,7 @@ export default {
this.$router.push({
name: 'Login',
query: {
two_factor: true
two_factor: 1
}
});
} else {
Expand All @@ -415,9 +426,26 @@ export default {
);
}
} else if (this.hasForgotPassword) {
this.$resources.resetPassword.submit({
email: this.email
});
await this.$resources.is2FAEnabled.submit(
{ user: this.email },
{
onSuccess: async two_factor_enabled => {
if (two_factor_enabled) {
this.$router.push({
name: 'Login',
query: {
two_factor: 1,
forgot: 1
}
});
} else {
await this.$resources.resetPassword.submit({
email: this.email
});
}
}
}
);
} else {
this.$resources.signup.submit();
}
Expand Down

0 comments on commit ba0007c

Please sign in to comment.