mirror of
https://gitlab.com/cyclane/sbdatatracker.git
synced 2025-04-19 12:25:05 +00:00
21 lines
519 B
TypeScript
21 lines
519 B
TypeScript
export enum Permissions {
|
|
ALL = "*",
|
|
VIEW_PROFILE = "view_profile",
|
|
ADD_PROFILE = "add_profile",
|
|
MANAGE_PERMISSIONS = "manage_permissions"
|
|
}
|
|
|
|
/**
|
|
* Check permissions
|
|
* @param required The permission required
|
|
* @param has The permissions to check against
|
|
* @returns Whether the required permissions are fulfilled
|
|
*/
|
|
export function checkPermissions(required: string[], has: string[]): boolean {
|
|
if (has.includes("*")) return true;
|
|
|
|
return !required.some(req => {
|
|
if (!has.includes(req)) return true;
|
|
});
|
|
}
|