-
Notifications
You must be signed in to change notification settings - Fork 17.8k
chore: Fix/remove hardcode of admin role #27779
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?
Changes from all commits
b7e9497
65424d5
9972913
cc20ec8
3fb0954
2baff80
95ef7cc
828cc5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,17 +24,17 @@ import { | |
| } from 'src/types/bootstrapTypes'; | ||
| import { Dashboard } from 'src/types/Dashboard'; | ||
| import { findPermission } from 'src/utils/findPermission'; | ||
| import getBootstrapData from 'src/utils/getBootstrapData'; | ||
|
|
||
| // this should really be a config value, | ||
| // but is hardcoded in backend logic already, so... | ||
| const ADMIN_ROLE_NAME = 'admin'; | ||
| const bootstrapData = getBootstrapData(); | ||
| const ADMIN_ROLE_NAME = bootstrapData.common.conf.AUTH_ROLE_ADMIN || 'Admin'; | ||
|
Comment on lines
+29
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incomplete test coverage for configurable admin role
The module-level Code Review Run #080cad Should Bito avoid suggestions like this for future reviews? (Manage Rules)
|
||
|
|
||
| export const isUserAdmin = ( | ||
| user?: UserWithPermissionsAndRoles | UndefinedUser, | ||
| ) => | ||
| isUserWithPermissionsAndRoles(user) && | ||
| Object.keys(user.roles || {}).some( | ||
| role => role.toLowerCase() === ADMIN_ROLE_NAME, | ||
| role => role.toLowerCase() === ADMIN_ROLE_NAME.toLowerCase(), | ||
| ); | ||
|
|
||
| const isUserDashboardOwner = ( | ||
|
|
||
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.
Mmmmh, seems
ADMIN_ROLE_NAME != AUTH_ROLE_ADMIN. AUTH_ROLE_ADMIN probably exist do it can diverge from the global ADMIN_ROLE - assuming this exists. Maybe FAB exposes it somewhere? Would have to be carried to the frontend?