add userHasPermission helper
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useUserStore } from "../store/UserStore";
|
||||
import { extractFileNameFromUrl } from "./url";
|
||||
|
||||
/**
|
||||
@@ -102,3 +103,14 @@ export const generateRandomElementId = (prefix: string = ""): string => {
|
||||
|
||||
return randomId;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return if the current user has a permission.
|
||||
*
|
||||
* @param {string} permission The permission to check.
|
||||
* @returns {boolean} If the user has the permission.
|
||||
*/
|
||||
export const userHasPermission = (permission: string): boolean => {
|
||||
const userStore = useUserStore();
|
||||
return userStore.permissions && userStore.permissions.includes(permission);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user