Commit d1b42669 by Antti Vesanen

Issue #90: Näytä virheilmoitus kirjautumisen epäonnistuessa

1 parent 42255cc4
......@@ -153,6 +153,7 @@
<p:fieldset id="leftuserinfo" rendered="#{!sessionHandler.loggedIn}">
<div style="text-align: left; padding: 0.7em;">
<h:form>
<h:outputText rendered="#{authView.loginError}" styleClass="error" value="#{i18n['loginerror.message']}" /><br />
<p:inputText styleClass="form" id="linelogin" value="#{authView.login}" />
<p:watermark for="linelogin" value="#{i18n['login.username']}" />
<br />
......
......@@ -129,11 +129,17 @@ public class AuthView extends GenericCDIView {
doLogin(onError);
}
private boolean loginError = false;
public boolean isLoginError() {
return loginError;
}
private void doLogin(String onError) {
// bootStrapBean.saneDefaults();
if (login == null || password == null || login.isEmpty() || password.isEmpty()) {
logger.info("Username or password was empty");
this.loginError = true;
return;
}
......@@ -157,6 +163,7 @@ public class AuthView extends GenericCDIView {
try {
request.login(login.trim().toLowerCase(), password);
} catch (Exception e) {
this.loginError = true;
logger.info("Error while trying to login {}", e.getMessage());
} finally {
......@@ -168,11 +175,11 @@ public class AuthView extends GenericCDIView {
navihandler.redirectToSaved();
} else {
navihandler.forward(onError);
//navihandler.forward(onError);
try {
request.logout();
request.getSession().invalidate();
navihandler.forward("/frontpage?faces-redirect=true");
//navihandler.forward("/frontpage?faces-redirect=true");
} catch (ServletException e) {
logger.warn("Error while trying to relogin as anonymous", e);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!