I want to add the current URL(returnTo - string type) in this part of code :href="@routes.AuthenticationController.login(**returnTo**)". I want to use it to redirect to the requested URL after login. Right now if a user is not logged in, gets a message on the page with Unauthorized 403, and has to use the log in button that will redirect them to the login page.
For example if I am on http://localhost:9000/getByProductId/43, after the login I want to get to this page.
The login function looks like this:
public static Result login(String returnTo) {
return ok(views.html.forms.loginForm.render(form(Login.class), returnTo));
}
The page with restricted message looks like this
<div class="hero-unit center">
<h1>Access Restricted <small><font face="Tahoma" color="red">Unauthorized 403</font></small></h1>
<br />
@if(User.findCurrentUser() == null || User.findCurrentUser().getIdentifier() == null) {
<p>You have to login first to access this functionality.</p>
<p>
<a href="@routes.AuthenticationController.login(**returnTo**)" class="btn btn-large btn-info" ><i class="icon-home icon-white"></i> Log in</a>
}