permission system - permission formatting
This commit is contained in:
parent
d889f92643
commit
2f5d9d3f01
15 changed files with 352 additions and 18 deletions
|
@ -1,11 +1,16 @@
|
|||
import { PermissionObject } from "./permissionTypes";
|
||||
|
||||
export type JWTData = {
|
||||
[key: string]: string | number | Array<string>;
|
||||
[key: string]: string | number | PermissionObject;
|
||||
};
|
||||
|
||||
export type JWTToken = {
|
||||
userId: number;
|
||||
mail: string;
|
||||
username: string;
|
||||
rights: Array<string>;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
permissions: PermissionObject;
|
||||
} & JWTData;
|
||||
|
||||
export type JWTRefresh = {
|
||||
|
|
24
src/type/permissionTypes.ts
Normal file
24
src/type/permissionTypes.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
export type PermissionSection = "club" | "settings" | "user";
|
||||
|
||||
export type PermissionModule = "protocoll" | "user";
|
||||
|
||||
export type PermissionType = "read" | "create" | "update" | "delete";
|
||||
|
||||
export type PermissionString =
|
||||
| `${PermissionSection}.${PermissionModule}.${PermissionType}` // für spezifische Berechtigungen
|
||||
| `${PermissionSection}.${PermissionModule}.*` // für alle Berechtigungen in einem Modul
|
||||
| `${PermissionSection}.${PermissionType}` // für spezifische Berechtigungen in einem Abschnitt
|
||||
| `${PermissionSection}.*` // für alle Berechtigungen in einem Abschnitt
|
||||
| "*"; // für Admin
|
||||
|
||||
export type PermissionObject = {
|
||||
[section in PermissionSection]?: {
|
||||
[module in PermissionModule]?: Array<PermissionType> | "*";
|
||||
} & { all?: Array<PermissionType> | "*" };
|
||||
} & {
|
||||
admin?: boolean;
|
||||
};
|
||||
|
||||
export const permissionSections: Array<PermissionSection> = ["club", "settings", "user"];
|
||||
export const permissionModules: Array<PermissionModule> = ["protocoll", "user"];
|
||||
export const permissionTypes: Array<PermissionType> = ["read", "create", "update", "delete"];
|
Loading…
Add table
Add a link
Reference in a new issue