change: show only other user for owner transfer

This commit is contained in:
Julian Krauser 2025-02-07 13:26:42 +01:00
parent 117372af39
commit 88ec075d20
3 changed files with 18 additions and 12 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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";
</script>
<script lang="ts">
@ -116,15 +117,18 @@ export default defineComponent({
},
computed: {
...mapState(useUserStore, ["users", "loading"]),
...mapState(useAccountStore, ["id"]),
filtered(): Array<UserViewModel> {
return this.query === ""
? this.users
: this.users.filter((user) =>
(user.firstname + " " + user.lastname)
.toLowerCase()
.replace(/\s+/g, "")
.includes(this.query.toLowerCase().replace(/\s+/g, ""))
);
return (
this.query === ""
? this.users
: this.users.filter((user) =>
(user.firstname + " " + user.lastname)
.toLowerCase()
.replace(/\s+/g, "")
.includes(this.query.toLowerCase().replace(/\s+/g, ""))
)
).filter((u) => u.id != this.id);
},
},
mounted() {