-
-
Notifications
You must be signed in to change notification settings - Fork 107
(WIP) feat: add list
permission
#1921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 9 commits
0c27ea5
252de57
60f8f42
d5af457
48e3eb6
2244bc2
3d1e127
1ccc6ac
6879548
27bb3bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -277,6 +277,7 @@ export class PolicyUtil extends QueryUtils { | |||
create: { guard: true, inputChecker: true }, | ||||
update: { guard: true }, | ||||
delete: { guard: true }, | ||||
list: { guard: true }, | ||||
postUpdate: { guard: true }, | ||||
}, | ||||
}; | ||||
|
@@ -611,6 +612,11 @@ export class PolicyUtil extends QueryUtils { | |||
return false; | ||||
} | ||||
|
||||
if (!this.injectAuthGuardAsWhere(db, injected, model, 'list')) { | ||||
args.where = this.makeFalse(); | ||||
return false; | ||||
} | ||||
|
||||
if (args.where) { | ||||
// inject into fields: | ||||
// to-many: some/none/every | ||||
|
@@ -646,6 +652,14 @@ export class PolicyUtil extends QueryUtils { | |||
return true; | ||||
} | ||||
|
||||
/** | ||||
* Injects auth guard for read operations. | ||||
*/ | ||||
injectForList(_db: CrudContract, _model: string, _args: any) { | ||||
// make select and include visible to the injection | ||||
return true; | ||||
} | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ymc9 The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree this list logic should go inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That part of code is not entirely easy to comprehend 😄. Please feel free to pass the PR to me to finish when you reach a point where you feel the basics are working. |
||||
|
||||
//#endregion | ||||
|
||||
//#region Checker | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this is the kind of check we need to do here?