ปรับสิทธิ์

This commit is contained in:
setthawutttty 2024-10-09 14:49:22 +07:00
parent b356eef92f
commit c8a9dbb259
3 changed files with 27 additions and 22 deletions

View file

@ -5,6 +5,7 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { setAuthen, authenticated, tokenParsed } from "@/plugins/auth";
import type { QTableProps } from "quasar";
import type {
@ -193,13 +194,13 @@ function fetchUserDetail(id: string) {
function fetchlistRole() {
http
.get(config.API.managementRole)
.then((res) => {
roleOptions.value = res.data.filter(
(e: Roles) =>
e.name === "STAFF" ||
e.name === "SUPER_ADMIN" ||
e.name === "ADMIN" ||
e.name === "USER"
.then(async (res) => {
const checkToken: any = await tokenParsed();
const roleSuper = await checkToken.role.includes("SUPER_ADMIN");
roleOptions.value = res.data.filter((e: Roles) =>
roleSuper
? ["STAFF", "SUPER_ADMIN", "ADMIN", "USER"].includes(e.name)
: ["STAFF", "USER"].includes(e.name)
);
})
.catch((err) => {