Conversation
Co-authored-by: kheimerl <1043359+kheimerl@users.noreply.github.com>
|
@philion I had claude make a PR, how's it look? |
|
My read is that it's not adding a specific user role, but instead generating a new UUID? |
| Future<void> createUserRole({ | ||
| required String userId, | ||
| }) async { | ||
| final roleId = const UuidV4().generate(); |
There was a problem hiding this comment.
like, shouldn't this be a set role and not a UUID?
There was a problem hiding this comment.
The current (this is how I found it) implementation maps user_profile_id to the role enum. The id field is to identify the row. I don't think it's necessary, and the user_profile_id could be both primary and foreign key (I think).
| await _supabaseClient.from('user_roles').insert({ | ||
| 'id': roleId, | ||
| 'user_profile_id': userId, | ||
| 'role': 'USER', |
There was a problem hiding this comment.
or is this where its setting it to "USER" by default? Shouldn't that be a const somewhere?
There was a problem hiding this comment.
It doesn't need to be set (or a row created) (I think) if the user doesn't need special privileges. "user" is assumed, never checked. Once you've logged in, you have access to what that user has access to.
This role is only checked a few places, determining when to display admin-level pages or features.
New users signing up were never assigned a role, leaving
user_rolesempty and breaking role-based access control for those accounts.Changes
UserService: AddedcreateUserRole()method that inserts auser_rolesrow with the default'USER'role for the given user IDUserRepository.createNewUser(): CallscreateUserRole()after profile and person creation, before invalidating the signup codeThe
'USER'string matches theAppRoles.USERenum member name as stored in the PostgreSQLapp_rolesenum, consistent with how the Python backend seeds users inupdate_db_sample_data.py.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.