Skip to content

Use config collections object to populate select field's options (circular dependency) #5046

Answered by tsemachh
revnelson asked this question in Q&A
Discussion options

You must be logged in to vote
import { Access } from 'payload';
import { RolePermissions, User } from '@/payload-types'
import { Role } from '@/payload-types';

export const canUserAccessAction = (user: User | null | undefined, slugName: string, action: string) => {
  if (user) {
    if (user.isAdmin) return true;

    if (!user.userRoles || user.userRoles.length == 0) return false;

    const userRoles: Role[] = user.userRoles as Role[];
    // if (! userRoles[0].permissions) return false;
    const permissions: (RolePermissions | undefined) = userRoles[0].permissions
    if (!permissions) return false
    for (const permission of permissions)
      if (((permission.entity as string[]).includes(slugName)) && ((permis…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@revnelson
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by revnelson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants