Skip to content

[BUG] Field level @deny generates function that denies access regardless whether true or false #811

Closed
@jasonmacdonald

Description

@jasonmacdonald

Description and expected behavior
The generated @ deny function will cause the policy to fail regardless of whether it evaluates to true or false, as the return object is always the same { OR: [] }.

Example:

...
role         Role     @deny('update', auth().role != 'ADMIN')
....
  @@allow('create,update,delete', auth().role == 'ADMIN')
  @@allow('update', auth() == this)
  @@allow('read', true)

Generated Function

function Membership$role_update(context, db) {
    const user = (0, runtime_1.hasAllFields)(context.user, ['id']) ? context.user : null;
    if (((user === null || user === void 0 ? void 0 : user.role) != 'ADMIN')) {
        return { OR: [] };
    }
    return { OR: [] };
}

Environment (please complete the following information):

  • ZenStack version: 1.2.0
  • Prisma version :5.2.2
  • Database type: Postgresql

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions