Skip to content

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

feat: add redirect in signin/signup page (#1786)

boojackf85eeacda492
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 9fd275f9c2..2976a8d10f 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -941,11 +941,29 @@ router.beforeEach((to, from, next) => {
return;
} else {
if (!isLoggedIn) {
- next({ name: SIGNIN_MODULE, replace: true });
+ const query: any = {};
+ if (to.fullPath !== "/") {
+ query["redirect"] = to.fullPath;
+ }
+
+ next({
+ name: SIGNIN_MODULE,
+ query: query,
+ replace: true,
+ });
return;
}
}
+ // If there is a `redirect` in query param and prev page is signin or signup, redirect to the target route
+ if (
+ (from.name === SIGNIN_MODULE || from.name === SIGNUP_MODULE) &&
+ typeof from.query.redirect === "string"
+ ) {
+ window.location.href = from.query.redirect;
+ return;
+ }
+
const currentUser = authStore.currentUser;
if (to.name?.toString().startsWith("setting.workspace.version-control")) {