Skip to content

Instantly share code, notes, and snippets.

@reyjexter
Created October 11, 2013 11:21
Show Gist options
  • Save reyjexter/6933141 to your computer and use it in GitHub Desktop.
Save reyjexter/6933141 to your computer and use it in GitHub Desktop.
def submitLogin = Action.async { implicit request =>
val futureForm = scala.concurrent.Future { loginForm.bindFromRequest }
futureForm.map(form => {
form.fold(
formWithErrors => BadRequest(html.auth.login(formWithErrors)),
resultForm => {
resultForm match {
case (username, password) => {
val futureUser = User.findByUsername(username)
futureUser.map { user =>
Logger.debug("Login success")
User.updateLastLogin(user.get)
Redirect(admin.routes.Dashboard.index).withSession(Security.username -> user.get.username, "role" -> user.get.role)
}
}
}
}
)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment