Skip to content

Commit

Permalink
[391] API de connexion : [email protected] (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucien Pereira authored and jdauphant committed Jan 16, 2020
1 parent f591620 commit 042342f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/controllers/LoginController.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 042342f

Please sign in to comment.