You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2025. It is now read-only.
After #1212 goes in it will not be possible to create events or venues from their respective dashboards (dashboard/venues and dashboard/events).
It would be nice if we brought back that functionality, updated to reflect the new permissions system. Specifically:
As an instance owner, I can go to the events/venues dashboard, click on 'add new' and then be able to create an event/venue for any chapter
As a chapter admin, I can go to to the events/venues dashboard, click on 'add new' and then be able to create an event/venue for the chapters I am an admin of
I was exploring ways to do this, I'm having hard time with finding good way to return appropriate list of admined chapters from server. In other words - differentiating between instance owner that can have all chapters, and filtering only chapters admined as chapter admin.
Ideal would be single query, that would return appropriate chapters. There's however problem with authorizing for it.
For instance owner some permission with @Authorize can be used, but this will not work for chapter admin.
Not using @Authorize decorator would require some additional logic in the resolver, to figure out if user has instance owner permissions or not.
Some alternatives:
Running two different queries? One for instance owner returning all chapters, and if that fails - user is not authorized, run another to return only admined chapters?
Client side filtering?
All this feels convoluted and more complicated than it should be.
Thanks for the detailed breakdown, it really helped.
I've got a couple of ideas for how to attack this. (Two is probably the most sensible, but it's up for debate)
One
give both instance owners and chapter admins the ListChapters instance permission.
have the server send, respectively, all the chapters or all the chapters that that user administrates
My logic was just this: both instance users and chapter admins need to know which chapters they control. Any permission has to be a instance permission, because, without making a query how do they know which chapterIds to send? If they don't know those ids (and have chapter level permissions) they'll be rejected by Auth.
Two
return the chapterIds in response to the useMeQuery
It doesn't seem like a user should need special permission to see information about themselves (since that's all this really is - we're not talking about letting you see info about other users). So how about sending it as part of the user data that every user needs?
I like both of these. I agree it might not be really needed to additionally authorize listing of the admined chapters, after all, user not admining any chapter would simply receive empty list.
This still leaves the need to include some permission logic in query listing admined chapters. With pseudocode:
query list admined chapters {
if (is instance owner aka can admin all chapaters) {
return all chapters
} else {
return only chapters explicitly admined
}
}
So I guess my question is, if it's okay to mix that here, and if there's any sort of preference in how to do that?
Okay, so let's say we with go with approach two. Then, yeah, it's still necessary to do some logic inside the me resolver (i.e. your pseudocode). I think that's a fine solution.
I see what you mean about mixing permission logic into the resolver, but I think it's okay. The authChecker is still doing its one job (restricting access to resolvers) and the resolver is still doing its job (responding to queries that reach it). The fact that it has to respond differently based on req.user is probably okay - certainly for what you're working on.
If we find ourselves wanting to make queries like "get me all the venues of all the chapters I'm an admin of" we might need something cleverer, but let's wait and see if that comes up.
Activity
gikf commentedon Aug 1, 2022
I was exploring ways to do this, I'm having hard time with finding good way to return appropriate list of admined chapters from server. In other words - differentiating between instance owner that can have all chapters, and filtering only chapters admined as chapter admin.
Ideal would be single query, that would return appropriate chapters. There's however problem with authorizing for it.
@Authorizecan be used, but this will not work for chapter admin.@Authorizedecorator would require some additional logic in the resolver, to figure out if user has instance owner permissions or not.Some alternatives:
All this feels convoluted and more complicated than it should be.
ojeytonwilliams commentedon Aug 2, 2022
Thanks for the detailed breakdown, it really helped.
I've got a couple of ideas for how to attack this. (Two is probably the most sensible, but it's up for debate)
One
ListChaptersinstance permission.My logic was just this: both instance users and chapter admins need to know which chapters they control. Any permission has to be a instance permission, because, without making a query how do they know which chapterIds to send? If they don't know those ids (and have chapter level permissions) they'll be rejected by Auth.
Two
useMeQueryIt doesn't seem like a user should need special permission to see information about themselves (since that's all this really is - we're not talking about letting you see info about other users). So how about sending it as part of the user data that every user needs?
gikf commentedon Aug 4, 2022
I like both of these. I agree it might not be really needed to additionally authorize listing of the admined chapters, after all, user not admining any chapter would simply receive empty list.
This still leaves the need to include some permission logic in query listing admined chapters. With pseudocode:
So I guess my question is, if it's okay to mix that here, and if there's any sort of preference in how to do that?
ojeytonwilliams commentedon Aug 4, 2022
Okay, so let's say we with go with approach two. Then, yeah, it's still necessary to do some logic inside the me resolver (i.e. your pseudocode). I think that's a fine solution.
I see what you mean about mixing permission logic into the resolver, but I think it's okay. The authChecker is still doing its one job (restricting access to resolvers) and the resolver is still doing its job (responding to queries that reach it). The fact that it has to respond differently based on
req.useris probably okay - certainly for what you're working on.If we find ourselves wanting to make queries like "get me all the venues of all the chapters I'm an admin of" we might need something cleverer, but let's wait and see if that comes up.