SetRole sets the role matching the given name. This will add a role that does not yet exist, and overwrite an existing role.
(role Role)
| 99 | // SetRole sets the role matching the given name. This will add a role that does not yet exist, and overwrite an |
| 100 | // existing role. |
| 101 | func SetRole(role Role) { |
| 102 | // We want to ignore invalid roles, which should not exist outside specific circumstances (like during login) |
| 103 | if role.id == 0 { |
| 104 | return |
| 105 | } |
| 106 | if existingRole, ok := globalDatabase.rolesByID[role.id]; ok { |
| 107 | delete(globalDatabase.rolesByName, existingRole.Name) |
| 108 | } |
| 109 | globalDatabase.rolesByName[role.Name] = role.id |
| 110 | globalDatabase.rolesByID[role.ID()] = role |
| 111 | } |
| 112 | |
| 113 | // IsSuperUser returns whether the given role is a SUPERUSER. |
| 114 | func IsSuperUser(role RoleID) bool { |
no test coverage detected