提交 f76fdaec 编写于 作者: F frizbog

Issue 1634. Changed failed authentication so try again link keeps track of...

Issue 1634.  Changed failed authentication so try again link keeps track of where you were when you tried logging in, and the login link returns you to the top page if you click it while logging in.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9623 71c3de6d-444a-0410-be80-ed276b4c234a
上级 6ad22bb2
package hudson.security;
import org.acegisecurity.ui.webapp.AuthenticationProcessingFilter;
import org.kohsuke.stapler.Stapler;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import hudson.model.Hudson;
import org.acegisecurity.AuthenticationException;
import org.acegisecurity.ui.webapp.AuthenticationProcessingFilter;
/**
* {@link AuthenticationProcessingFilter} with a change for Hudson so that
......@@ -18,6 +18,7 @@ public class AuthenticationProcessingFilter2 extends AuthenticationProcessingFil
@Override
protected String determineTargetUrl(HttpServletRequest request) {
String targetUrl = request.getParameter("from");
request.getSession().setAttribute("from", targetUrl);
if (targetUrl == null)
return getDefaultTargetUrl();
......@@ -32,4 +33,16 @@ public class AuthenticationProcessingFilter2 extends AuthenticationProcessingFil
return targetUrl;
}
/**
* @see org.acegisecurity.ui.AbstractProcessingFilter#determineFailureUrl(javax.servlet.http.HttpServletRequest, org.acegisecurity.AuthenticationException)
*/
@Override
protected String determineFailureUrl(HttpServletRequest request, AuthenticationException failed) {
Properties excMap = getExceptionMappings();
String failedClassName = failed.getClass().getName();
String whereFrom = request.getParameter("from");
request.getSession().setAttribute("from", whereFrom);
return excMap.getProperty(failedClassName, getAuthenticationFailureUrl());
}
}
......@@ -6,8 +6,8 @@
<l:main-panel>
<div style="margin: 2em; text-align:center; color:red; font-weight:bold">
${%Invalid login information. Please try again.}
<br/>
<a href="loginEntry">${%Try again}</a>
<br/>
<a href="login?from=${request.session.getAttribute('from')}">${%Try again}</a>
</div>
</l:main-panel>
</l:layout>
......
<a style="color:inherit" href="${rootURL}/${app.securityRealm.loginUrl}?from=${request.requestURI}"><b>${%login}</b></a>
<a style="color:inherit" href="${rootURL}/${app.securityRealm.loginUrl}?from=${if (request.session.attribute('from')!=null) request.session.getAttribute('from'); else if (request.getParameter('from')!=null) request.getParameter('from'); else if (request.requestURI=='/loginError' || request.requestURI=='/login') '/'; else request.requestURI;} "><b>${%login}</b></a>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册