-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Summary
Add a built-in property app.role to automatically determine user roles based on authorized actions, eliminating the need for manual role parsing.
Current Implementation
Currently, developers need to manually implement role determination logic like this:
def get_identify_role(authorized_actions: list[str], method: str) -> IdentifyRole:
if f'user_role.{method}' in authorized_actions:
return IdentifyRole.user
else:
return IdentifyRole.supportProposed Solution
Provide a clean API through app.role that automatically determines the role based on the authorization context, similar to how app.current_user_id works.
Benefits
- Reduces boilerplate code across applications
- Centralizes role determination logic
- Provides consistent role handling across the platform
- Improves code maintainability
References
- PR: https://github.com/cuenca-mx/identify/pull/316
- Discussion: https://github.com/cuenca-mx/identify/pull/316#discussion_r2292457460
Requested by: @felipao-mx
Metadata
Metadata
Assignees
Labels
No labels