Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 865aad8

Browse files
Allow u-bahn role users to perform almost same actions as admin, except admin
1 parent 9b4b224 commit 865aad8

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/common/helper.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ function injectSearchMeta (req, res, result) {
221221
* @param recordObj the record object
222222
*/
223223
function permissionCheck (auth, recordObj) {
224-
if (auth && auth.roles && !checkIfExists(auth.roles, [appConst.UserRoles.admin, appConst.UserRoles.administrator]) &&
224+
if (
225+
auth &&
226+
auth.roles &&
227+
!checkIfExists(auth.roles, appConst.AdminUser) &&
228+
!checkIfExists(auth.roles, [appConst.UserRoles.ubahn]) &&
225229
recordObj.createdBy !== getAuthUser(auth)) {
226230
throw errors.newPermissionError('You are not allowed to perform this action')
227231
}

src/consts.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ const UserRoles = {
66
admin: 'Admin',
77
administrator: 'Administrator',
88
topcoderUser: 'Topcoder User',
9-
copilot: 'Copilot'
9+
copilot: 'Copilot',
10+
ubahn: 'u-bahn'
1011
}
1112
/**
1213
* all authenticated users.
1314
* @type {(string)[]}
1415
*/
15-
const AllAuthenticatedUsers = [UserRoles.admin, UserRoles.administrator, UserRoles.topcoderUser, UserRoles.copilot]
16+
const AllAuthenticatedUsers = [
17+
UserRoles.admin,
18+
UserRoles.administrator,
19+
UserRoles.topcoderUser,
20+
UserRoles.copilot,
21+
UserRoles.ubahn
22+
]
1623

1724
/**
1825
* all admin user

src/modules/usersSkill/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747
delete: {
4848
method: Controller.remove,
4949
auth: 'jwt',
50-
access: consts.AdminUser,
50+
access: [...consts.AdminUser, consts.UserRoles.ubahn],
5151
scopes: ['delete:usersSkill', 'all:usersSkill']
5252
}
5353
}

0 commit comments

Comments
 (0)