diff --git a/src/main/java/info/bukova/isspst/SessionData.java b/src/main/java/info/bukova/isspst/SessionData.java index 65feebf2..6d0fa7a2 100644 --- a/src/main/java/info/bukova/isspst/SessionData.java +++ b/src/main/java/info/bukova/isspst/SessionData.java @@ -19,9 +19,10 @@ public class SessionData implements Serializable { private List userWorkgroups; private User currentUser; private Map> workgroupRoles; + private boolean loginFailed; public SessionData() { - + loginFailed = false; } public List getUserCentres() { @@ -56,4 +57,12 @@ public class SessionData implements Serializable { this.workgroupRoles = workgroupRoles; } + public boolean isLoginFailed() { + return loginFailed; + } + + public void setLoginFailed(boolean loginFailed) { + this.loginFailed = loginFailed; + } + } diff --git a/src/main/java/info/bukova/isspst/security/LoginFailHandler.java b/src/main/java/info/bukova/isspst/security/LoginFailHandler.java index 10e2313d..c8a018bd 100644 --- a/src/main/java/info/bukova/isspst/security/LoginFailHandler.java +++ b/src/main/java/info/bukova/isspst/security/LoginFailHandler.java @@ -1,5 +1,7 @@ package info.bukova.isspst.security; +import info.bukova.isspst.SessionData; + import java.io.IOException; import javax.servlet.ServletException; @@ -8,17 +10,25 @@ import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AuthenticationFailureHandler; public class LoginFailHandler implements AuthenticationFailureHandler { + @Autowired + private SessionData sessionData; + @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex) throws IOException, ServletException { Logger logger = LoggerFactory.getLogger(LoginFailHandler.class); logger.info("Login failed with message: " + ex.getMessage()); + + sessionData.setLoginFailed(true); + + response.sendRedirect("app/"); } diff --git a/src/main/java/info/bukova/isspst/ui/LoginVM.java b/src/main/java/info/bukova/isspst/ui/LoginVM.java new file mode 100644 index 00000000..07a2facd --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/LoginVM.java @@ -0,0 +1,24 @@ +package info.bukova.isspst.ui; + +import org.zkoss.bind.annotation.Init; +import org.zkoss.zk.ui.select.annotation.WireVariable; + +import info.bukova.isspst.SessionData; + +public class LoginVM { + + @WireVariable + private SessionData sessionData; + + @Init + public void init() { + + } + + public boolean isLoginFailed() { + boolean isFailed = sessionData.isLoginFailed(); + sessionData.setLoginFailed(false); + return isFailed; + } + +} diff --git a/src/main/webapp/login.zul b/src/main/webapp/login.zul index 239539c7..46a63b50 100644 --- a/src/main/webapp/login.zul +++ b/src/main/webapp/login.zul @@ -1,7 +1,10 @@ - - + + +