@@ -69,14 +69,14 @@ Let’s take a look at all the permissions of the Post and how they could be exp
6969
7070the owner must be set to the current user, and the organization must be set to one that the current user belongs to.
7171``` tsx
72- @@allow (' create' , owner == auth () && org .members ? [this == auth ()])
72+ @@allow (' create' , owner == auth () && org .members ? [id == auth (). id ])
7373` ` `
7474- Update
7575
7676 only the owner can update it and is not allowed to change the organization or owner
7777
7878 ` ` ` tsx
79- @@allow (' update' , owner == auth () && org .future ().members ? [this == auth ()] && future ().owner == owner )
79+ @@allow (' update' , owner == auth () && org .future ().members ? [id == auth (). id ] && future ().owner == owner )
8080 ` ` `
8181- Read
8282
@@ -86,7 +86,7 @@ the owner must be set to the current user, and the organization must be set to o
8686 ` ` `
8787 - allow the member of the organization to read it if it’s public
8888 ` ` ` tsx
89- @@allow (' read' , isPublic && org .members ? [this == auth ()])
89+ @@allow (' read' , isPublic && org .members ? [id == auth (). id ])
9090 ` ` `
9191 - allow the group members to read it
9292 ` ` ` tsx
@@ -117,15 +117,15 @@ abstract model organizationBaseEntity {
117117 groups Group[]
118118
119119 // when create, owner must be set to current user, and user must be in the organization
120- @@allow(' create' , owner == auth () && org.members?[this == auth()])
120+ @@allow(' create' , owner == auth () && org.members?[id == auth().id ])
121121 // only the owner can update it and is not allowed to change the owner
122- @@allow(' update' , owner == auth () && org.members?[this == auth()] && future().owner == owner)
122+ @@allow(' update' , owner == auth () && org.members?[id == auth().id ] && future().owner == owner)
123123 // allow owner to read
124124 @@allow(' read' , owner == auth ())
125125 // allow shared group members to read it
126- @@allow(' read' , groups ? [users ?[this == auth ()]])
126+ @@allow(' read' , groups ? [users ?[id == auth (). id ]])
127127 // allow organization to access if public
128- @@allow(' read' , isPublic && org.members?[this == auth ()])
128+ @@allow(' read' , isPublic && org.members?[id == auth (). id ])
129129 // can not be read if deleted
130130 @@deny(' all' , isDeleted == true )
131131}
@@ -152,7 +152,7 @@ model ToDo extends organizationBaseEntity {
152152All the multi-tenant, soft delete and sharing features will just work automatically. Additionally, if any specialized access control logic is required for ** ` ToDo ` **, such as allowing shared individuals to update it, you can effortlessly add the corresponding policy rule within the ** ` ToDo ` ** model without concerns about breaking existing functionality:
153153
154154` ` ` tsx
155- @@allow (' update' , groups ? [users ? [this == auth ()]] )
155+ @@allow (' update' , groups ? [users ? [id == auth (). id ]] )
156156` ` `
157157
158158## How much Typescript/JavaScript code do I need to write
0 commit comments