Update ssg and editor access functions
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
tobias 2024-05-20 11:41:41 +02:00
parent ff564a62ec
commit 747ada89e9
2 changed files with 14 additions and 2 deletions

View File

@ -3,10 +3,10 @@ import { User } from "../payload-types";
export const isEditor: Access<any, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an editor role
return Boolean(user?.roles?.includes('editor', 'admin'));
return Boolean(user?.roles?.some(role => ['user', 'editor', 'admin'].includes(role)));
}
export const isEditorFieldLevel: FieldAccess<{ id: string }, unknown, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an editor role
return Boolean(user?.roles?.includes('editor', 'admin'));
return Boolean(user?.roles?.some(role => ['user', 'editor', 'admin'].includes(role)));
}

View File

@ -0,0 +1,12 @@
import { Access, FieldAccess } from "payload/types";
import { User } from "../payload-types";
export const isSSG: Access<any, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an ssg or admin role
return Boolean(user?.roles?.some(role => ['ssg', 'admin'].includes(role)));
}
export const isSSGFieldLevel: FieldAccess<{ id: string }, unknown, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an ssg or admin role
return Boolean(user?.roles?.some(role => ['ssg', 'admin'].includes(role)));
}