From 042342f365087b3fd2587d51fa38a005fab52d81 Mon Sep 17 00:00:00 2001 From: Lucien Pereira Date: Thu, 16 Jan 2020 11:22:24 +0100 Subject: [PATCH] [391] API de connexion : login?email=toto@email.com (#430) --- app/controllers/LoginController.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/LoginController.scala b/app/controllers/LoginController.scala index cb3adc2e6..f9ad3c001 100644 --- a/app/controllers/LoginController.scala +++ b/app/controllers/LoginController.scala @@ -1,11 +1,10 @@ package controllers import actions.RequestWithUserData -import extentions.UUIDHelper import javax.inject.{Inject, Singleton} import models.{Area, LoginToken, User} import org.webjars.play.WebJarsUtil -import play.api.mvc.{InjectedController, Request, Result} +import play.api.mvc.InjectedController import services.{EventService, NotificationService, TokenService, UserService} @Singleton @@ -17,8 +16,11 @@ class LoginController @Inject()(userService: UserService, private lazy val tokenExpirationInMinutes = configuration.underlying.getInt("app.tokenExpirationInMinutes") def login() = Action { implicit request => - val emailFromRequest: Option[String] = request.body.asFormUrlEncoded.flatMap(_.get("email").flatMap(_.headOption)).orElse(request.flash.get("email")) - emailFromRequest.fold { + val emailFromRequestOrQueryParamOrFlash: Option[String] = request.body.asFormUrlEncoded + .flatMap(_.get("email").flatMap(_.headOption)) + .orElse(request.getQueryString("email")) + .orElse(request.flash.get("email")) + emailFromRequestOrQueryParamOrFlash.fold { Ok(views.html.loginHome(Left(None))) } { email => userService.byEmail(email).fold {