-
Notifications
You must be signed in to change notification settings - Fork 6
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
rfc: add single place for defining page authorization checks #908
base: main
Are you sure you want to change the base?
Conversation
Target extends Targeted<Capability> = Targeted<Capability>, | ||
>( | ||
page: T, | ||
userId: UsersId, |
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.
Since this is always called in a context where we've already retrieved the full user row, it would be nice to make this function accept a User
here and then check user.isSuperAdmin
before making the capabilities query. I miss my superadmin privileges in communities I'm not a member of 😄
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.
good idea!
apiTokens: Capabilities.editCommunity, | ||
docs: Capabilities.editCommunity, | ||
apiDocs: [Capabilities.editCommunity, Capabilities.viewPub], | ||
} as const satisfies PageAuthorizationCheckMap; |
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 agree, this is much nicer than what we've been doing!
I'm not sure how I feel about this approach. On one hand, it does keep the page checks very concise, but it adds ~200 lines of code to do so. What about something like this? await pageCheck(
Capabilities.editCommunity,
community.id, // infers that this must be a community id from the provided capability
user.id, // or a user object
) And just like |
Issue(s) Resolved
High-level Explanation of PR
Test Plan
Screenshots (if applicable)
Notes