Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: check mfa token when login (#13809)

boojack6c7cfb940003
diff --git a/frontend/src/components/PasswordSigninForm.vue b/frontend/src/components/PasswordSigninForm.vue
index 01789ab776..e4d0c57f61 100644
--- a/frontend/src/components/PasswordSigninForm.vue
+++ b/frontend/src/components/PasswordSigninForm.vue
@@ -89,7 +89,7 @@ import { NButton } from "naive-ui";
import { computed, reactive } from "vue";
import { useRoute, useRouter } from "vue-router";
import { BBTextField } from "@/bbkit";
-import { AUTH_PASSWORD_RESET_MODULE } from "@/router/auth";
+import { AUTH_MFA_MODULE, AUTH_PASSWORD_RESET_MODULE } from "@/router/auth";
import { useAuthStore } from "@/store";
interface LocalState {
@@ -133,18 +133,28 @@ const trySignin = async () => {
if (state.isLoading) return;
state.isLoading = true;
try {
- const { requireResetPassword } = await authStore.login({
+ const { mfaTempToken, requireResetPassword } = await authStore.login({
email: state.email,
password: state.password,
web: true,
});
+ if (mfaTempToken) {
+ router.push({
+ name: AUTH_MFA_MODULE,
+ query: {
+ mfaTempToken,
+ redirect: route.query.redirect as string,
+ },
+ });
+ return;
+ }
if (requireResetPassword) {
router.push({
name: AUTH_PASSWORD_RESET_MODULE,
});
- } else {
- router.push("/");
+ return;
}
+ router.push("/");
} finally {
state.isLoading = false;
}
diff --git a/frontend/src/views/OAuthCallback.vue b/frontend/src/views/OAuthCallback.vue
index 0150fbd101..ac17d58d9b 100644
--- a/frontend/src/views/OAuthCallback.vue
+++ b/frontend/src/views/OAuthCallback.vue
@@ -86,6 +86,7 @@ const triggerAuthCallback = async () => {
);
window.close();
} else {
+ // We don't need to check password reset for SSO login.
const { mfaTempToken } = await authStore.login({
idpName: eventName.split(".").pop()!,
idpContext: {
diff --git a/frontend/src/views/auth/MultiFactor.vue b/frontend/src/views/auth/MultiFactor.vue
index 415c91b336..28ea24c240 100644
--- a/frontend/src/views/auth/MultiFactor.vue
+++ b/frontend/src/views/auth/MultiFactor.vue
@@ -70,6 +70,7 @@ import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import { BBTextField } from "@/bbkit";
+import { AUTH_PASSWORD_RESET_MODULE } from "@/router/auth";
import { useAuthStore } from "@/store";
type MFAType = "OTP" | "RECOVERY_CODE";
@@ -114,11 +115,18 @@ const challenge = async () => {
} else if (state.selectedMFAType === "RECOVERY_CODE") {
mfaContext.recoveryCode = state.recoveryCode;
}
- await authStore.login({
+ const { requireResetPassword } = await authStore.login({
web: true,
mfaTempToken: mfaTempToken.value,
...mfaContext,
});
+ // Check if the user needs to reset their password after MFA passed.
+ if (requireResetPassword) {
+ router.push({
+ name: AUTH_PASSWORD_RESET_MODULE,
+ });
+ return;
+ }
router.replace(redirectUrl.value || "/");
};
</script>
diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vue
index a46d5b1899..21f0c61b2e 100644
--- a/frontend/src/views/auth/Signin.vue
+++ b/frontend/src/views/auth/Signin.vue
@@ -287,10 +287,12 @@ const allowSignin = (idpName?: string) => {
return state.email && state.password;
};
+// Mainly for LDAP signin and demo signin.
const trySignin = async (idpName?: string) => {
if (state.isLoading) return;
state.isLoading = true;
try {
+ // For LDAP signin, we don't need to check requireResetPassword.
const { mfaTempToken } = await authStore.login({
email: state.email,
password: state.password,
@@ -305,9 +307,9 @@ const trySignin = async (idpName?: string) => {
redirect: route.query.redirect as string,
},
});
- } else {
- router.push("/");
+ return;
}
+ router.push("/");
} finally {
state.isLoading = false;
}