in app/controllers/Auth.scala [143:192]
private def userProfileFromJWT(response: Either[String, JWTClaimsSet]) = {
response match {
case Left(err)=>Future(Left(err))
case Right(oAuthResponse)=>
userProfileDAO.userProfileForEmail(oAuthResponse.getUserID).flatMap({
case None=>
logger.info(s"No user profile existing for ${oAuthResponse.getUserID}, creating one")
var newUserProfile = UserProfile(
oAuthResponse.getUserID,
oAuthResponse.getIsMMAdminFromRole,
Option(oAuthResponse.getStringClaim("given_name")),
Option(oAuthResponse.getStringClaim("family_name")),
Seq(),
allCollectionsVisible=true,
None,
Option(oAuthResponse.getStringClaim("location")),
None,
None,
None,
None
)
if (config.get[String]("oAuth.type") != "Azure") {
newUserProfile = UserProfile(
oAuthResponse.getUserID,
oAuthResponse.getIsMMAdmin,
Option(oAuthResponse.getStringClaim("first_name")),
Option(oAuthResponse.getStringClaim("family_name")),
Seq(),
allCollectionsVisible=true,
None,
Option(oAuthResponse.getStringClaim("location")),
None,
None,
None,
None
)
}
userProfileDAO
.put(newUserProfile)
.map(Right.apply)
.recover({
case err:Throwable=>
logger.error(s"Could not save user profile for ${newUserProfile.userEmail}: ${err.getMessage}", err)
Left(err.getMessage)
})
case Some(Left(dynamoErr))=>Future(Left(dynamoErr.toString))
case Some(Right(userProfile))=>Future(Right(userProfile))
})
}
}