Při zadání špatného loginu nebo hesla se objeví chybová hláška v
přihlašovacím okně.
This commit is contained in:
@@ -19,9 +19,10 @@ public class SessionData implements Serializable {
|
||||
private List<Workgroup> userWorkgroups;
|
||||
private User currentUser;
|
||||
private Map<Integer, List<Role>> workgroupRoles;
|
||||
private boolean loginFailed;
|
||||
|
||||
public SessionData() {
|
||||
|
||||
loginFailed = false;
|
||||
}
|
||||
|
||||
public List<Workgroup> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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/");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
<?page title="Přihlášení" contentType="text/x-component;charset=UTF-8"?>
|
||||
<zk>
|
||||
|
||||
<window title="Přihlášení" border="normal" width="300px">
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
<window title="Přihlášení" border="normal" width="300px"
|
||||
apply="org.zkoss.bind.BindComposer"
|
||||
viewModel="@id('vm') @init('info.bukova.isspst.ui.LoginVM')">
|
||||
<label value="Špatný login nebo heslo!" style="font-weight:bold; font-size: 14px; color: red;" visible="@load(vm.loginFailed)"/>
|
||||
<html style="font-family:arial,sans-serif;font-size:12px;">
|
||||
<![CDATA[
|
||||
<form name='loginForm' action="j_spring_security_check"
|
||||
@@ -20,7 +23,7 @@ method='POST'>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2'><input name="submit" type="submit"
|
||||
value="Přihlásit" />
|
||||
value="Přihlásit" class="nicebutton" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user