I chose WO to develop a Web Application (instead of RoR)..
Now.. I'm doing a login form.. Looking a screencast from David LeBer I moved the LoginAction from my Main.java file to DirectAction.
Everything works fine.. but ... One thing is annoying.
public WOActionResults loginAction() {
WOComponent nextPage = null;
String password = request().stringFormValueForKey("password");
String username = request().stringFormValueForKey("username");
String errorMessage = null;
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
errorMessage = "Username o password necessari";
password = null;
}
else
try {
User currentUser;
EOQualifier qualifier = User.USERNAME.eq(username).and(User.PASSWORD.eq(password));
currentUser = User.fetchRequiredUser(ERXEC.newEditingContext(),qualifier);
if (! currentUser.active()) {
errorMessage = "Utente attualmente disabilitato. Contattare l'amministratore";
password = null;
currentUser = null;
nextPage = pageWithName(Main.class.getName());
nextPage.takeValueForKey(errorMessage, "errorMessage");
nextPage.takeValueForKey(username, "username");
return nextPage;
}
((Session)session()).setCurrentUser(currentUser);
String pageToRedirect = currentUser.group().mainPage();
if (pageToRedirect==null)
;
else {
nextPage = pageWithName(pageToRedirect);
}
}
catch (NoSuchElementException e) {
errorMessage = "Utente non trovato o password sbagliata";
}
catch (Exception e) {
NSLog.out.appendln("Some exceptions during login");
}
if (! StringUtils.isEmpty(errorMessage)) {
nextPage = pageWithName(Main.class.getName());
nextPage.takeValueForKey(errorMessage, "errorMessage");
nextPage.takeValueForKey(username, "username");
}
return nextPage;
}
Then... this is the URL after the action:
even when it's redirect to the WOComponent...
If someone refresh the page, a new login action is done, changing the session.
I'd like to have, after the login, the url changed to something like
so if someone press refresh the login action is not called...
Any help?