From bd0566bb0c6cf5cb9cdd8286fe0a8067858103b5 Mon Sep 17 00:00:00 2001 From: sadnub Date: Mon, 21 Oct 2024 11:29:51 -0400 Subject: [PATCH] allow dispay full name in UI if present --- src/layouts/MainLayout.vue | 4 ++-- src/stores/auth.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index e598a69c..750c8a41 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -157,7 +157,7 @@ - + { diff --git a/src/stores/auth.ts b/src/stores/auth.ts index 68fe6f78..57db6375 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -28,6 +28,7 @@ interface TOTPSetupResponse { export const useAuthStore = defineStore("auth", { state: () => ({ username: useStorage("user_name", null), + name: useStorage("name", null), token: useStorage("access_token", null), ssoLoginProvider: useStorage("sso_provider", null), }), @@ -35,6 +36,9 @@ export const useAuthStore = defineStore("auth", { loggedIn: (state) => { return state.token !== null; }, + displayName: (state) => { + return state.name ? state.name : state.username; + }, }, actions: { async checkCredentials( @@ -45,12 +49,14 @@ export const useAuthStore = defineStore("auth", { if (!data.totp) { this.token = data.token; this.username = data.username; + this.name = data.name; } return data; }, async login(credentials: LoginRequest) { const { data } = await axios.post("/v2/login/", credentials); this.username = data.username; + this.name = data.name; this.token = data.token; this.ssoLoginProvider = null; @@ -64,6 +70,7 @@ export const useAuthStore = defineStore("auth", { } this.token = null; this.username = null; + this.name = null; this.ssoLoginProvider = null; }, async setupTotp(): Promise {