upgraded to shiro 1.4.0
enhanced error messages
This commit is contained in:
@ -41,7 +41,7 @@ public class LoginView implements Serializable {
|
||||
private String resetPasswordToken = null;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginView.class.getName());
|
||||
|
||||
|
||||
public void authenticate() {
|
||||
|
||||
// Example using most common scenario of username/password pair:
|
||||
@ -63,11 +63,15 @@ public class LoginView implements Serializable {
|
||||
String fallbackUrl = "/web/index.xhtml"; // TODO make configurable
|
||||
// ec.redirect(url);
|
||||
WebUtils.redirectToSavedRequest((ServletRequest) ec.getRequest(), (ServletResponse) ec.getResponse(), fallbackUrl);
|
||||
} catch (IOException | AuthenticationException e) {
|
||||
} catch (IOException | AuthenticationException ex) {
|
||||
// Could catch a subclass of AuthenticationException if you like
|
||||
String hint = "Error while authenticating user " + username;
|
||||
LOGGER.error(hint + "Reason: " + e.toString());
|
||||
FacesUtil.addErrorMessage("Login failed");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(hint, ex);
|
||||
} else {
|
||||
LOGGER.error(hint + " Reason: " + ex.toString());
|
||||
}
|
||||
FacesUtil.addErrorMessage("Login failed");
|
||||
|
||||
AccountEntity account = accountService.getAccountEntity(username, false);
|
||||
if (account != null) {
|
||||
@ -96,11 +100,11 @@ public class LoginView implements Serializable {
|
||||
boolean passwordResetted = accountService.resetPassword(username, password, resetPasswordToken);
|
||||
if (passwordResetted) {
|
||||
// TODO add email notification on updated user account
|
||||
FacesUtil.addInfoMessage ("Password resetted");
|
||||
FacesUtil.addInfoMessage("Password resetted");
|
||||
return login();
|
||||
} else {
|
||||
// TODO add email notificaton on failed password reset
|
||||
FacesUtil.addErrorMessage("Password reset failed");
|
||||
FacesUtil.addErrorMessage("Password reset failed");
|
||||
return login();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user