I know there are already articles that covered this, but I'm having an issue that hasn't been resolved, even after reading those articles.
Here it goes:
I have 2 controllers, a MainController with this method:
public static void login(String username, String password) throws Throwable
{
Secure.authenticate(username, password, false);
}
And a SecurityController, an extension of Secure.Security with this method:
//overrides Security.authenticate(...)
public static boolean authenticate(String username, String password) {
return UserDAO.checkUserLogin(username, password);
}
Then we have a view that pops out a small login screen (similar to that of twitter's login). That view calls @{MainController.login()} with the input fields named correctly
When the user clicks the login button, the login controlller should be called, with this behaviour: - Correct? Refer to the url the user came from - Incorrect? Show standard login panel with error message
But that does not happen:
Play redirects to the login page in any case, and always without an error flash. Simply the plain login screen, without any error messages.
(note that there should be indeed an error message, because the user does not exist in the db)
When I do create a user first, the application reacts t开发者_开发知识库he same way.
The url of the page login(...) redirects to is: http://localhost:9000/loginremember=false&password=secret&username=Bob
My question is now: Why does Play do this? Why doesn't it redirect to the page it came from (with redirectToOriginalUrl())? It shouldn't be giving those parameters to the login method of Secure, it should render at least the login screen with the error messages.
But even when I provide the details correctly, it still just redirects to the login view of the Secure module, with all the paramters.
What am I doing wrong?
Thanks beforehand, kind regards, Jasper
Fixed this issue with the implementation of a class that doesn't extend the Controller
class. Works fine.
Thanks @Felipe Oliveira!
精彩评论