Skip to content

Using this causes policy generation error in field-level access policies #665

Closed
@ymc9

Description

@ymc9
model User {
  id Int @id @default(autoincrement())
  admin Boolean @default(false)
  username String @unique @allow("all", auth() == this) @allow("all", auth().admin)
  password String @password @default("") @allow("all", auth() == this) @allow("all", auth().admin)
  firstName String @default("")
  lastName String @default("")

  @@allow('all', auth() == this)
  @@allow('all', auth().admin)
  @@allow('create', true)
}

Output:

node_modules/.zenstack/policy.ts:58:22 - error TS2304: Cannot find name 'id'.
58     return ((user == id) || (user?.admin ?? null))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions