From 88ec075d2071dd18e9c9314b4666e60b59e9ad62 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Fri, 7 Feb 2025 13:26:42 +0100 Subject: [PATCH] change: show only other user for owner transfer --- src/router/authGuard.ts | 6 +++--- src/stores/account.ts | 4 +++- src/views/account/Administration.vue | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/router/authGuard.ts b/src/router/authGuard.ts index a180065..d7e5be2 100644 --- a/src/router/authGuard.ts +++ b/src/router/authGuard.ts @@ -7,7 +7,7 @@ import type { PermissionObject } from "@/types/permissionTypes"; import { useAbilityStore } from "@/stores/ability"; export type Payload = JwtPayload & { - userId: number; + userId: string; username: string; firstname: string; lastname: string; @@ -67,7 +67,7 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro }); } - var { firstname, lastname, mail, username, permissions, isOwner } = decoded; + var { userId, firstname, lastname, mail, username, permissions, isOwner } = decoded; if (Object.keys(permissions ?? {}).length === 0 && !isOwner) { auth.setFailed(); @@ -75,7 +75,7 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro } auth.setSuccess(); - account.setAccountData(firstname, lastname, mail, username); + account.setAccountData(userId, firstname, lastname, mail, username); ability.setAbility(permissions, isOwner); resolve(decoded); } diff --git a/src/stores/account.ts b/src/stores/account.ts index 09e05c8..f3de2af 100644 --- a/src/stores/account.ts +++ b/src/stores/account.ts @@ -5,6 +5,7 @@ import { useAbilityStore } from "./ability"; export const useAccountStore = defineStore("account", { state: () => { return { + id: "" as string, firstname: "" as string, lastname: "" as string, mail: "" as string, @@ -17,7 +18,8 @@ export const useAccountStore = defineStore("account", { localStorage.removeItem("refreshToken"); window.open("/login", "_self"); }, - setAccountData(firstname: string, lastname: string, mail: string, alias: string) { + setAccountData(id: string, firstname: string, lastname: string, mail: string, alias: string) { + this.id = id; this.firstname = firstname; this.lastname = lastname; this.mail = mail; diff --git a/src/views/account/Administration.vue b/src/views/account/Administration.vue index 558e3a6..de72c68 100644 --- a/src/views/account/Administration.vue +++ b/src/views/account/Administration.vue @@ -103,6 +103,7 @@ import { } from "@headlessui/vue"; import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid"; import type { UserViewModel } from "@/viewmodels/admin/user/user.models"; +import { useAccountStore } from "@/stores/account";