Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: separate login methods in the frontend (#4108)
Danny Xu3105d30603e4
diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.tsindex 5800c63e8a..c89afe1670 100644--- a/frontend/src/store/modules/auth.ts+++ b/frontend/src/store/modules/auth.ts@@ -5,7 +5,8 @@ import { computed, Ref } from "vue";import {Principal,AuthState,- LoginInfo,+ AuthProviderType,+ VCSLoginInfo,SignupInfo,ActivateInfo,ResourceObject,@@ -50,28 +51,30 @@ export const useAuthStore = defineStore("auth", {this.setAuthProviderList(convertedProviderList);return convertedProviderList;},- async login(loginInfo: LoginInfo) {- if (loginInfo.authProvider == "BYTEBASE") {- await axios.post("/v1/auth/login", {- email: (loginInfo.payload as BytebaseLoginInfo).email,- password: (loginInfo.payload as BytebaseLoginInfo).password,- web: true,- });- const userId = getIntCookie("user");- if (userId) {- const loggedInUser = await usePrincipalStore().fetchPrincipalById(- userId- );+ async login(loginInfo: BytebaseLoginInfo) {+ await axios.post("/v1/auth/login", {+ email: loginInfo.email,+ password: loginInfo.password,+ web: true,+ });+ const userId = getIntCookie("user");+ if (userId) {+ const loggedInUser = await usePrincipalStore().fetchPrincipalById(+ userId+ );- this.setCurrentUser(loggedInUser);- return loggedInUser;- }- return unknown("PRINCIPAL") as Principal;+ this.setCurrentUser(loggedInUser);+ return loggedInUser;}-+ return unknown("PRINCIPAL") as Principal;+ },+ async vcsLogin(+ authProviderType: AuthProviderType,+ loginInfo: VCSLoginInfo+ ) {const loggedInUser = (- await axios.post(`/api/auth/login/${loginInfo.authProvider}`, {- data: { type: "loginInfo", attributes: loginInfo.payload },+ await axios.post(`/api/auth/login/${authProviderType}`, {+ data: { type: "loginInfo", attributes: loginInfo },})).data.data;// Refresh the corresponding principaldiff --git a/frontend/src/types/auth.ts b/frontend/src/types/auth.tsindex 3be1e80547..cc7bf792c8 100644--- a/frontend/src/types/auth.ts+++ b/frontend/src/types/auth.ts@@ -5,11 +5,6 @@ import { VCSId } from "./id";// For now, a single user's auth provider should either belong to GITLAB_SELF_HOST, GITHUB_COM or BYTEBASEexport type AuthProviderType = "GITLAB_SELF_HOST" | "GITHUB_COM" | "BYTEBASE";-export type LoginInfo = {- authProvider: AuthProviderType;- payload: VCSLoginInfo | BytebaseLoginInfo;-};-export type SignupInfo = {email: string;password: string;diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vueindex 21f1c0f0ad..d1075a04c8 100644--- a/frontend/src/views/auth/Signin.vue+++ b/frontend/src/views/auth/Signin.vue@@ -187,8 +187,6 @@ import { useRouter } from "vue-router";import {AuthProvider,EmptyAuthProvider,- VCSLoginInfo,- LoginInfo,OAuthWindowEventPayload,openWindowForOAuth,} from "../../types";@@ -251,15 +249,11 @@ export default defineComponent({if (payload.error) {return;}- const vcsLoginInfo: VCSLoginInfo = {- vcsId: state.activeAuthProvider.id,- name: state.activeAuthProvider.name,- code: payload.code,- };authStore- .login({- authProvider: state.activeAuthProvider.type,- payload: vcsLoginInfo,+ .vcsLogin(state.activeAuthProvider.type, {+ vcsId: state.activeAuthProvider.id,+ name: state.activeAuthProvider.name,+ code: payload.code,}).then(() => {router.push("/");@@ -267,16 +261,14 @@ export default defineComponent({};const trySignin = () => {- const loginInfo: LoginInfo = {- authProvider: "BYTEBASE",- payload: {+ authStore+ .login({email: state.email,password: state.password,- },- };- authStore.login(loginInfo).then(() => {- router.push("/");- });+ })+ .then(() => {+ router.push("/");+ });};const AuthProviderConfig = {