I´m having a problem redirecting from a play! form. I think the problem lies in how I´m handling the routes. The idea is that a user should be able to go to dashboard.html either by going first through index.hmtl using login from with a secruity key, or by typing directly in a valid path containing an access_token (using a qr-code redirection)
What I´m trying to do is as follows:
1) login using a form on index.html (route: Application.index)
Here is my form (located in index.html):
<form action="@{Dashboard.authenticate()}" method="POST" name="login">
<input name="key" type="password" maxlength="128" value="${flash.key}">
<input class="button" id="btnLogin" type="submit" value="Login">
</form>
2) authenticate and redirect to dashboard.html (route: Dashboard.dashboard)
public static void dashboard(String access_token) {
/*
...some code
*/
render(username);
}
public static void authenticate(String key) {
/*
...some code
*/
dashboard(access_token);
}
Here is my route file:
# Home page
GET / Application.index
POST /dashboard Dashboard.authenticate
GET /dashboard Dashboard.dashboard
The dashboard route works fine if I call directly upon dashboard(String access_token) through an URL like: http://localhost:9000/dashboard?access_token=0000
But if i try to login using the login form that calls upon authenticate(String key) I get this URL http://localhost:9000/dashboard?access_token&key=1234 where key is the var being sent to the auth()function. Clearly my fault lies with the routes, but I have tried and tested the logic and I am 100% certain it is sound.
I´m using Play 1.2.4
I have spent two days on this problem and would be most grateful for any suggestions.
Problem Solved!
What I forgot to mention…oops was that I am also using jQuery Mobile and the problem had to do with Play! routing being overriden my jQuery Mobile page routing.
I disabled the routing by adding the following script:
Using instructions on the jQuery website: http://jquerymobile.com/test/docs/api/globalconfig.html I implemented the above but the script needs to referenced in the .hmtml header in the following order: