-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi
I wanted to use a popup modal login form.
After clicking a secured button with reload/redirect action, and successful authentication not the window itself, but the login popup will reload/redirect itself. Is there a way to reload/redirect the original page after succesfull login?
links in zul Page:
<button id="btn_login1" label="Login" onClick="sendRedirect("./admin/index.zul");"/>
<button id="btn_login2" label="Login" onClick="sendRedirect(null);"/>
applicationContext-security.xml:
<zksp:zk-event >
<zksp:form-login login-page="/login.zul" authentication-failure-url="/login.zul?login_error=1"/>
<zksp:intercept-event event="onClick" path="//**/btn_*" access="ROLE_SUPERVISOR"/>
<zksp:intercept-event path="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
</zksp:zk-event>
maybe I should change the login.zul?
<h:form id="f" name="f" action="j_spring_security_check" method="POST"
xmlns:h="http://www.w3.org/1999/xhtml">
...
</h:form>
an add some kind of parent reload after spring login action?
Thanks:
Bence
Have a try with this modified line.
<zksp:form-login login-page="/login.zul" authentication-failure-url="/login.zul?login_error=1" default-target-url="./admin/index.zul"/>
Hi, Terry
Thanks for the quick reply.
If I write exactly what you wrote the application throw an exception in bootstrapping stage:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'defaultTargetUrl' threw exception; nested exception is java.lang.IllegalArgumentException: defaultTarget must start with '/' or with 'http(s)'
If I delete the '.', the result is a different browser error message (in grey popup window) after clicking the button:
Error creating bean with name 'self': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'self': Requested bean is currently in creation: Is there an unresolvable circular reference?
and then an apache-style error message after logging in:
HTTP Status 404 - /admin/~./zul/zkspring/security/loginOKTemplate.zul
Any tips?
the problem is that ZK spring resolve template file using a context path.
copy org.zkoss.spring.security.ui.ZkLoginOKFilter file to you source folder ,and replace the source below
original source:
------------------
if(loginOKTemplate == null)
loginOKTemplate = "ZKSPRING_SECURITY_LOGIN_OK_TEMPLATE";
replace with
--------------
if(loginOKTemplate == null) {
loginOKTemplate = "ZKSPRING_SECURITY_LOGIN_OK_TEMPLATE";
}else {
loginOKTemplate = "/"+loginOKTemplate;
}
Hi
I don't understand why should I need any loginOkTemplate.
The only thing I want: if somebody want to go to a restricted area, and does not have rights to do that then it should get a modal popup window, and only if he/she can authenticate as an admin, then the modal disappears and the parent page redirects to the page he/she wanted to go. If he/she click X or Cancel then stays on the page where he/she was before. Is there an easy way to solve this with ZK + ZKSpring security?
JasonHao: your patch does not change anything. This only does not do the trick. If I click to that button:
<button id="btn_login1" label="Login" onClick="sendRedirect("./admin/index.zul");"/>
If I try this one too:
<zksp:form-login login-page="/login.zul" authentication-failure-url="/login.zul?login_error=1" default-target-url="./admin/index.zul"/>
cvc-complex-type.3.2.2: Attribute 'default-target-url' is not allowed to appear in element 'zksp:form-login'.
What do you suggest? Forgot the fancy modal-popup concept, and use tomcat security, since it does something similar? (just does not have any integration with spring security)
Regards:
Bence
as far as I know, the loginOKTemplate is called automatically when your authentication is succeed, which makes a delay before turn to your login succeed destination. and the delay period can be defined in <zksp:form-login section .
Asked: 2009-12-07 06:37:43 +0800
Seen: 4,336 times
Last updated: Apr 26 '10