i have the following customized security controller using the secure module for play:
public class Security extends Secure.Security {
static boolean authenticate(String username, String password) {
validation.required(username);
validation.required(password);
if (!validation.hasErrors()) {
BetaUser user = BetaUser.find("username", username).first();
if (user != null && user.password.equals(password)) {
Session.current().put("userid", user.id);
return true;
}
return false;
}
else {
return false;
}
}
static void onAuthenticated() {
Series.userSeries();
}
static void onDisconnected() {
Application.index();
}
static boolean check(String profile) {
if ("admin".equals(profile)) {
return Security.connected().equals("admin");
}
return false;
}
}
In this case the validation mechanism in the authenticate methode works. When i use annotations the password parameter doesn`t get validatet anymore:
static boolean authenticate(@Required String username, @Required String password) {
if (!validation.hasErrors()) {
BetaUser user = BetaUser.find("username", username).first();
if (user != null && user.password.equals(password)) {
Session.current().put("userid", user.id);
return true;
}
return false;
}
else {
return false;
}
}
The strange thing is, that the username validation actually does work (error when username is empty). When only the password is left empty the validation has no errors...
I hope that you can help me.