generated from autonomic-cooperative/astro-payload-template
Update ssg and editor access functions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ff564a62ec
commit
747ada89e9
@ -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)));
|
||||
}
|
12
payload/src/access/isSSG.ts
Normal file
12
payload/src/access/isSSG.ts
Normal 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)));
|
||||
}
|
Loading…
Reference in New Issue
Block a user