Skip to content

Commit

Permalink
fixed error accepting user access request (#1793)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Ricci <[email protected]>
  • Loading branch information
SteRiccio and SteRiccio authored Sep 16, 2021
1 parent 3bc9f0e commit 4d1372b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion server/modules/auth/manager/authManager.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export { fetchGroupByUuid, updateUserGroup, fetchSurveyGroups } from '../repository/authGroupRepository'
export {
fetchGroupByName,
fetchGroupByUuid,
updateUserGroup,
fetchSurveyGroups,
} from '../repository/authGroupRepository'
11 changes: 11 additions & 0 deletions server/modules/auth/repository/authGroupRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ export const insertUserGroup = async (groupUuid, userUuid, client = db) =>

// ==== READ

export const fetchGroupByName = async ({ name }, client = db) =>
client.one(
`
SELECT auth_group.*
FROM auth_group
WHERE auth_group.name = $1
AND auth_group.survey_uuid IS NULL`,
[name],
dbTransformCallback
)

export const fetchGroupByUuid = async (groupUuid, client = db) =>
client.one(
`
Expand Down
2 changes: 1 addition & 1 deletion server/modules/user/service/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export const acceptUserAccessRequest = async ({ user, serverUrl, accessRequestAc
// 3) find group to associate to the user
let group = null
if ([AuthGroup.groupNames.systemAdmin, AuthGroup.groupNames.surveyManager].includes(role)) {
group = User.getAuthGroupByName(role)(user)
group = await AuthManager.fetchGroupByName({ name: role }, t)
} else {
const surveyGroups = await AuthManager.fetchSurveyGroups(Survey.getId(survey), t)
group = surveyGroups.find((surveyGroup) => AuthGroup.getName(surveyGroup) === role)
Expand Down

0 comments on commit 4d1372b

Please sign in to comment.