Question

I'm using playframework 2.2 to develop a web site(java language), and I used securesocial to enable login with facebook/twitter. but after I customized my login page as securesocial suggested, I found that no error message is shown when there is an error.

here is the LoginView, I pass msg to view:


class LoginViews(application: play.api.Application) extends DefaultTemplatesPlugin(application)
{
 /**
   * Returns the html for the login page
   * @param request
   * @tparam A
   * @return
   */
  override def getLoginPage[A](implicit request: Request[A], form: Form[(String, String)],
                               msg: Option[String] = None): Html =
  {
      views.html.Login(msg)
  }
....
}

and this is my html:


@(msg: Option[String] = None)

@import play.api.mvc.Request
@import play.api.data.Form

@main("Login -- Tranest", null) {
    @msg.map { m =>
        
            @Messages(m)
        
    }
}
Was it helpful?

Solution

A cookie is set with a default error message ( I think you can customize it) on the request.
Try adding this in the controller and pass the error ( Option[String]) in your view.

val error = request.cookies.get("PLAY_FLASH").map(_.value)

This shoud do the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top