change: show only other user for owner transfer
This commit is contained in:
parent
117372af39
commit
88ec075d20
3 changed files with 18 additions and 12 deletions
|
@ -7,7 +7,7 @@ import type { PermissionObject } from "@/types/permissionTypes";
|
||||||
import { useAbilityStore } from "@/stores/ability";
|
import { useAbilityStore } from "@/stores/ability";
|
||||||
|
|
||||||
export type Payload = JwtPayload & {
|
export type Payload = JwtPayload & {
|
||||||
userId: number;
|
userId: string;
|
||||||
username: string;
|
username: string;
|
||||||
firstname: string;
|
firstname: string;
|
||||||
lastname: 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) {
|
if (Object.keys(permissions ?? {}).length === 0 && !isOwner) {
|
||||||
auth.setFailed();
|
auth.setFailed();
|
||||||
|
@ -75,7 +75,7 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
auth.setSuccess();
|
auth.setSuccess();
|
||||||
account.setAccountData(firstname, lastname, mail, username);
|
account.setAccountData(userId, firstname, lastname, mail, username);
|
||||||
ability.setAbility(permissions, isOwner);
|
ability.setAbility(permissions, isOwner);
|
||||||
resolve(decoded);
|
resolve(decoded);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { useAbilityStore } from "./ability";
|
||||||
export const useAccountStore = defineStore("account", {
|
export const useAccountStore = defineStore("account", {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
|
id: "" as string,
|
||||||
firstname: "" as string,
|
firstname: "" as string,
|
||||||
lastname: "" as string,
|
lastname: "" as string,
|
||||||
mail: "" as string,
|
mail: "" as string,
|
||||||
|
@ -17,7 +18,8 @@ export const useAccountStore = defineStore("account", {
|
||||||
localStorage.removeItem("refreshToken");
|
localStorage.removeItem("refreshToken");
|
||||||
window.open("/login", "_self");
|
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.firstname = firstname;
|
||||||
this.lastname = lastname;
|
this.lastname = lastname;
|
||||||
this.mail = mail;
|
this.mail = mail;
|
||||||
|
|
|
@ -103,6 +103,7 @@ import {
|
||||||
} from "@headlessui/vue";
|
} from "@headlessui/vue";
|
||||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
||||||
import type { UserViewModel } from "@/viewmodels/admin/user/user.models";
|
import type { UserViewModel } from "@/viewmodels/admin/user/user.models";
|
||||||
|
import { useAccountStore } from "@/stores/account";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -116,15 +117,18 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useUserStore, ["users", "loading"]),
|
...mapState(useUserStore, ["users", "loading"]),
|
||||||
|
...mapState(useAccountStore, ["id"]),
|
||||||
filtered(): Array<UserViewModel> {
|
filtered(): Array<UserViewModel> {
|
||||||
return this.query === ""
|
return (
|
||||||
? this.users
|
this.query === ""
|
||||||
: this.users.filter((user) =>
|
? this.users
|
||||||
(user.firstname + " " + user.lastname)
|
: this.users.filter((user) =>
|
||||||
.toLowerCase()
|
(user.firstname + " " + user.lastname)
|
||||||
.replace(/\s+/g, "")
|
.toLowerCase()
|
||||||
.includes(this.query.toLowerCase().replace(/\s+/g, ""))
|
.replace(/\s+/g, "")
|
||||||
);
|
.includes(this.query.toLowerCase().replace(/\s+/g, ""))
|
||||||
|
)
|
||||||
|
).filter((u) => u.id != this.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue