Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
If user is not logged in, we assign a Guest user.
天舟53f6e6723001
diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vueindex 5394d2cc95..ce18dd1e21 100644--- a/frontend/src/components/ProfileDropdown.vue+++ b/frontend/src/components/ProfileDropdown.vue@@ -106,9 +106,7 @@ export default {store.dispatch("auth/logout").then(() => {- // If using router.push, looks like hook reactive to currentUser would get called first.- // So we just do a reload here.- location.reload();+ router.push({ name: "auth.signin" });}).catch((error: Error) => {console.log(error);diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex f23ca636e0..f29881872e 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -17,6 +17,7 @@ import Activate from "../views/auth/Activate.vue";import PasswordReset from "../views/auth/PasswordReset.vue";import { store } from "../store";import { isDev, idFromSlug } from "../utils";+import { User } from "../types";const HOME_MODULE = "workspace.home";const AUTH_MODULE = "auth";@@ -330,7 +331,8 @@ export const router = createRouter({});router.beforeEach((to, from, next) => {- const loginUser = store.getters["auth/currentUser"]();+ const loginUser: User = store.getters["auth/currentUser"]();+ const isGuest = loginUser.id == "0";const fromModule = from.name? from.name.toString().split(".")[0]@@ -352,7 +354,7 @@ router.beforeEach((to, from, next) => {to.name === ACTIVATE_MODULE ||to.name === PASSWORD_RESET_MODULE) {- if (loginUser) {+ if (!isGuest) {next({ name: HOME_MODULE, replace: true });} else {if (to.name === ACTIVATE_MODULE) {@@ -370,7 +372,7 @@ router.beforeEach((to, from, next) => {}return;} else {- if (!loginUser) {+ if (isGuest) {next({ name: SIGNIN_MODULE, replace: true });return;}diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.tsindex dffe3e9e43..4cd8b37af6 100644--- a/frontend/src/store/modules/auth.ts+++ b/frontend/src/store/modules/auth.ts@@ -8,6 +8,13 @@ import {ResourceObject,} from "../../types";+const GUEST: User = {+ id: "0",+ status: "ACTIVE",+ name: "Guest",+ email: "[email protected]",+};+function convert(user: ResourceObject): User {return {id: user.id,@@ -16,11 +23,11 @@ function convert(user: ResourceObject): User {}const state: () => AuthState = () => ({- currentUser: null,+ currentUser: GUEST,});const getters = {- currentUser: (state: AuthState) => () => {+ currentUser: (state: AuthState) => (): User => {if (state.currentUser) {return state.currentUser;}@@ -28,7 +35,7 @@ const getters = {if (user) {return JSON.parse(user);}- return null;+ return GUEST;},};@@ -85,8 +92,8 @@ const actions = {async logout({ commit }: any) {localStorage.removeItem("bb.auth.user");- commit("setCurrentUser", null);- return null;+ commit("setCurrentUser", GUEST);+ return GUEST;},};