Skip to content

Commit

Permalink
Ignore the picture from Microsoft OAuth data
Browse files Browse the repository at this point in the history
It requires authorization to fetch, logic which we don't have yet.

Fixes #1447
  • Loading branch information
mikesname committed Mar 6, 2024
1 parent 53bd388 commit 24a7a38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ case class MicrosoftOAuth2Provider(config: play.api.Configuration) extends OAuth
guid <- (json \ "sub").asOpt[String]
email <- (json \ "email").asOpt[String]
name <- (json \ "name").asOpt[String]
picture = (json \ "picture").asOpt[String]
// NB: picture is not an image URL but requires authorization to fetch further data
// For the time being ignore this field
} yield UserData(
providerId = guid,
email = email,
name = name,
imageUrl = picture
imageUrl = None
)
} catch {
case e: JsonParseException =>
Expand Down
9 changes: 1 addition & 8 deletions modules/portal/app/views/Helpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,7 @@ object Helpers {
* Fetch a gravitar URL for the user, defaulting to the stock picture.
*/
def gravitar(img: Option[String]): String =
img.map(_.replaceFirst("https?://", "//"))
.getOrElse(controllers.portal.routes.PortalAssets.at("img/default-gravitar.png").url)

def remoteGravitar(userId: String): String = {
val hash = DigestUtils.md5Hex(s"$userId@ehri-project.eu")
s"https://secure.gravatar.com/avatar/$hash?d=identicon"
}

img.getOrElse(controllers.portal.routes.PortalAssets.at("img/default-gravitar.png").url)

def virtualUnitUrl(path: Seq[Model], id: String): Call = {
if (path.isEmpty) controllers.portal.routes.VirtualUnits.browseVirtualCollection(id)
Expand Down

0 comments on commit 24a7a38

Please sign in to comment.