diff --git a/grails-app/conf/application.yml b/grails-app/conf/application.yml index 1c39298b..62a8aae7 100644 --- a/grails-app/conf/application.yml +++ b/grails-app/conf/application.yml @@ -88,6 +88,9 @@ grails: taglib: none staticparts: none +userProfile: + userIdAttribute: "username" + environments: test: server: diff --git a/grails-app/services/au/org/ala/ecodata/forms/UserInfoService.groovy b/grails-app/services/au/org/ala/ecodata/forms/UserInfoService.groovy index 275a9211..c8b12684 100644 --- a/grails-app/services/au/org/ala/ecodata/forms/UserInfoService.groovy +++ b/grails-app/services/au/org/ala/ecodata/forms/UserInfoService.groovy @@ -120,7 +120,7 @@ class UserInfoService { def optUserProfile = alaOidcClient.getUserProfile(credentials, context, config.sessionStore) if (optUserProfile.isPresent()) { def userProfile = optUserProfile.get() - String userId = userProfile.userId ?: userProfile.getAttribute('username') + String userId = userProfile?.userId ?: userProfile?.getAttribute(grailsApplication.config.getProperty('userProfile.userIdAttribute')) if (userId) { return authService.getUserForUserId(userId) }