8000 Property 'X' does not exist on type 'AuthorizableUser<Role, string>' · Issue #762 · getjerry/nest-casl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Property 'X' does not exist on type 'AuthorizableUser<Role, string>' #762
Open
@AhmedElTabarani

Description

@AhmedElTabarani

I tried to access some fields like workspaceTeamId

type Subjects = InferSubjects<typeof User> | 'all';

export const permissions: Permissions<Role, Subjects, Actions> = {
  super_admin({ can }) {
    can(Actions.manage, 'all');
  },

  user({ user, cannot }) {
    cannot(Actions.read, User, {
      workspaceTeamId: { $ne: user.workspaceTeamId }, // <- Error Property 'workspaceTeamId' does not exist on type 'AuthorizableUser<Role, string>'
   }).because('You can only read users in your workspace');  },
};

I got this error

Property 'workspaceTeamId' does not exist on type 'AuthorizableUser<Role, string>'

app.module

@Module({
  imports: [
    CaslModule.forRoot<
      Role,
      { id: Types.ObjectId; roles: Role[] },
      { user: UserDocument }
    >({
      superuserRole: Role.SUPER_ADMIN,
      getUserFromRequest: (request) => ({
        id: request.user._id.toString(),
        ...request.user,
      }),
    }),
    // ....
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0