The request must be passed explicitely to the login template, the login template must pass the request explicitely to the provider template and the provider template must specify the request when invoking RoutesHelper.authenticateByPost("userpass").absoluteURL. More detailed:
The java TemplatesPlugin should have this getLoginPage implementation:
@Override public <A> Html getLoginPage(final play.api.mvc.Request<A> request, final Form<Tuple2<String, String>> form, final Option<String> msg) { return views.html.login.render(request, form, msg); }
The parameters (first line) of
login.scala.html
should look like this:@(request: play.api.mvc.RequestHeader, loginForm: play.api.data.Form[(String,String)], errorMsg: Option[String] = None)
Change calls from
login.scala.html
to theprovider
template to pass the request explicitely (we'll adjust its parameters in the next step).login.scala.html
line 41, change@provider(p.id)
to
@provider(request, p.id)
login.scala.html
line 55, change@provider("userpass", Some(loginForm))
to
@provider(request, "userpass", Some(loginForm))
The parameters (first line) of
provider.scala.html
should take the request as first, explicit parameter:@(request: play.api.mvc.RequestHeader, providerId: String, loginForm: Option[play.api.data.Form[(String, String)]] = None)
Line 20 of the provider template needs to pass the request (so that the correct method is invoked, otherwise you'll get a
RuntimeException: There is no HTTP Context available from here
):<form action = "@securesocial.core.providers.utils.RoutesHelper.authenticateByPost("userpass").absoluteURL(IdentityProvider.sslEnabled)(request)"
This should be all needed changes, if you're using other templates they would have to be adjusted accordingly.
Just to mentiond it: I had changed our java TemplatesPlugin to a scala version (to have it more straight forward).