From 1829a5c0db6329fb503eb6a0d01161781b864ca6 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 25 Jul 2014 14:20:57 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99i=20zad=C3=A1n=C3=AD=20=C5=A1patn=C3=A9h?= =?UTF-8?q?o=20loginu=20nebo=20hesla=20se=20objev=C3=AD=20chybov=C3=A1=20h?= =?UTF-8?q?l=C3=A1=C5=A1ka=20v=20p=C5=99ihla=C5=A1ovac=C3=ADm=20okn=C4=9B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/info/bukova/isspst/SessionData.java | 11 ++++++++- .../isspst/security/LoginFailHandler.java | 10 ++++++++ .../java/info/bukova/isspst/ui/LoginVM.java | 24 +++++++++++++++++++ src/main/webapp/login.zul | 9 ++++--- 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/ui/LoginVM.java 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 @@ - - + + +