mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 07:07:17 +01:00
Fixed components build. Renamed validations to permissions.
This commit is contained in:
parent
f0ec24e8f5
commit
c916e4ff9c
80 changed files with 99 additions and 373 deletions
29
src/permissions/user.ts
Normal file
29
src/permissions/user.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { Auth } from '@/lib/types';
|
||||
|
||||
export async function canCreateUser({ user }: Auth) {
|
||||
return user.isAdmin;
|
||||
}
|
||||
|
||||
export async function canViewUser({ user }: Auth, viewedUserId: string) {
|
||||
if (user.isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return user.id === viewedUserId;
|
||||
}
|
||||
|
||||
export async function canViewUsers({ user }: Auth) {
|
||||
return user.isAdmin;
|
||||
}
|
||||
|
||||
export async function canUpdateUser({ user }: Auth, viewedUserId: string) {
|
||||
if (user.isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return user.id === viewedUserId;
|
||||
}
|
||||
|
||||
export async function canDeleteUser({ user }: Auth) {
|
||||
return user.isAdmin;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue