Skip to content

Commit

Permalink
Disable user management endpoints if admin is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
vknaisl committed Sep 19, 2024
1 parent d449c81 commit 0763ca5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions wizard-server/src/Wizard/Service/User/UserService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ createUserByAdmin :: UserCreateDTO -> AppContextM UserDTO
createUserByAdmin reqDto =
runInTransaction $ do
checkPermission _UM_PERM
checkIfAdminIsDisabled
uUuid <- liftIO generateUuid
tenantUuid <- asks currentTenantUuid
clientUrl <- getClientUrl
Expand All @@ -97,6 +98,7 @@ createUserByAdminWithUuid reqDto uUuid tenantUuid clientUrl shouldSendRegistrati
registerUser :: UserCreateDTO -> AppContextM UserDTO
registerUser reqDto =
runInTransaction $ do
checkIfAdminIsDisabled
checkIfRegistrationIsEnabled
uUuid <- liftIO generateUuid
uPasswordHash <- generatePasswordHash reqDto.password
Expand All @@ -111,6 +113,7 @@ registerUser reqDto =
createUser :: UserCreateDTO -> U.UUID -> String -> String -> [String] -> U.UUID -> String -> Bool -> AppContextM UserDTO
createUser reqDto uUuid uPasswordHash uRole uPermissions tenantUuid clientUrl shouldSendRegistrationEmail =
runInTransaction $ do
checkIfAdminIsDisabled
checkUserLimit
checkActiveUserLimit
validateUserEmailUniqueness reqDto.email tenantUuid
Expand Down Expand Up @@ -276,6 +279,7 @@ deleteUser :: U.UUID -> AppContextM ()
deleteUser userUuid =
runInTransaction $ do
checkPermission _UM_PERM
checkIfAdminIsDisabled
_ <- findUserByUuid userUuid
deleteAuditByCreatedBy userUuid
clearBranchCreatedBy userUuid
Expand Down Expand Up @@ -321,3 +325,6 @@ sendAnalyticsEmailIfEnabled user = do

checkIfRegistrationIsEnabled =
checkIfTenantFeatureIsEnabled "Registration" (\c -> c.authentication.internal.registration.enabled)

checkIfAdminIsDisabled =
checkIfServerFeatureIsEnabled "User Management Endpoints" (\s -> not s.admin.enabled)

0 comments on commit 0763ca5

Please sign in to comment.