This commit is contained in:
parent
2cfca5e7cf
commit
e63dd42b6c
@ -1,7 +1,7 @@
|
|||||||
import { Access, FieldAccess } from 'payload/types'
|
import { Access } from 'payload/types'
|
||||||
import type { User } from 'types/payload-types'
|
import type { User } from 'types/payload-types'
|
||||||
|
|
||||||
export const isAdmin = ({ req: { user } }) => {
|
export const isAdmin = ({ req: { user } }: any) => {
|
||||||
if (user && user.roles?.includes('admin')) {
|
if (user && user.roles?.includes('admin')) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -9,7 +9,7 @@ export const isAdmin = ({ req: { user } }) => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isAdminOrCreatedBy = ({ req: { user } }) => {
|
export const isAdminOrCreatedBy = ({ req: { user } }: any) => {
|
||||||
if (user && user.role === 'admin') {
|
if (user && user.role === 'admin') {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ export const isAdminOrCreatedBy = ({ req: { user } }) => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isAdminOrSelf = ({ req: { user } }) => {
|
export const isAdminOrSelf = ({ req: { user } }: any) => {
|
||||||
if (user) {
|
if (user) {
|
||||||
if (user.roles?.includes('admin')) {
|
if (user.roles?.includes('admin')) {
|
||||||
return true
|
return true
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Access, FieldAccess } from 'payload/types'
|
import { Access, FieldAccess } from 'payload/types'
|
||||||
import type { User } from 'types/payload-types'
|
import type { User } from 'types/payload-types'
|
||||||
|
|
||||||
export const isEditor = ({ req: { user } }) => {
|
export const isEditor = ({ req: { user } }: any) => {
|
||||||
if (user?.roles?.some((role) => ['editor', 'admin'].includes(role))) {
|
if (user?.roles?.some((role) => ['editor', 'admin'].includes(role))) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Access, FieldAccess } from 'payload/types'
|
import { Access, FieldAccess } from 'payload/types'
|
||||||
import type { User } from 'types/payload-types'
|
import type { User } from 'types/payload-types'
|
||||||
|
|
||||||
export const isUser = ({ req: { user } }) => {
|
export const isUser = ({ req: { user } }: any) => {
|
||||||
if (user?.roles?.some((role) => ['user', 'editor', 'admin'].includes(role))) {
|
if (user && user?.roles?.some((role: string) => ['user', 'editor', 'admin'].includes(role))) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user