-
-
Notifications
You must be signed in to change notification settings - Fork 127
Closed
Labels
Milestone
Description
ZModel
model User {
id Int @id @default(autoincrement())
role String
@@allow('read', true)
@@allow('update', auth().id == id || auth().role == 'superadmin' || auth().role == 'admin')
@@deny('update',
(role == 'superadmin' && auth().id != id)
|| (role == 'admin' && auth().id != id && auth().role != 'superadmin')
|| (role != future().role && auth().role != 'admin' && auth().role != 'superadmin')
|| (role != future().role && future().role == 'superadmin')
|| (role != future().role && future().role == 'admin' && auth().role != 'superadmin')
)
}TS
const admin = await prisma.user.create({
data: { role: 'admin' },
});
const user = await prisma.user.create({
data: { role: 'customer' },
});
// the following line should succeed but got regjected
await enhance(prisma, { user: admin }).user.update({
where: { id: user.id },
data: { role: 'staff' },
});