-
-
Notifications
You must be signed in to change notification settings - Fork 315
feat: add role management and dynamic permissions #224
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: master
Are you sure you want to change the base?
Conversation
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public async Task<List<string>> GetUserPermission(string userId) | ||
| { | ||
| var userRoles = await _userRoleRepository.QueryAsync(x => x.UserId == userId); | ||
| if (userRoles.Any(x=>x.Role == Role.SuperAdmin)) | ||
| var roleIds = userRoles.Select(x => x.RoleId).Distinct().ToList(); | ||
| if (!roleIds.Any()) | ||
| { | ||
| return Template_SuperAdminPermissions; | ||
| return new List<string>(); | ||
| } | ||
|
|
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.
Migrate legacy user roles when computing permissions
PermissionService.GetUserPermission now derives permissions solely from RoleId, but existing agc_user_role rows created before this change only populate the old role column (now LegacyRoleValue). When GetUserPermission is invoked before any migration runs, the roleIds list is empty and the method returns an empty permission set, causing every authorization check (e.g. PermissionCheckAttribute) to reject requests for users with still-legacy rows until they happen to go through UserService.GetUserRolesAsync. The permission service should map legacy values or trigger the migration itself so upgraded deployments do not lock out users with existing tokens.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_b_68f65e375a808329b216387d873bdfe3