Skip to content
Snippets Groups Projects
Commit 18d426cf authored by Julian Hochstetter's avatar Julian Hochstetter
Browse files

Task #3833

parent b168e4d4
Branches
Tags
No related merge requests found
package de.thm.arsnova;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
public class LoginAuthenticationSucessHandler extends SimpleUrlAuthenticationSuccessHandler {
private String targetUrl;
@Override
protected String determineTargetUrl(HttpServletRequest request,
HttpServletResponse response) {
HttpSession session = request.getSession();
if (session == null || session.getAttribute("ars-referer") == null) {
return targetUrl;
}
String referer = (String) session.getAttribute("ars-referer");
return referer + targetUrl;
}
public void setTargetUrl(String targetUrl) {
this.targetUrl = targetUrl;
}
}
...@@ -75,6 +75,7 @@ public class LoginController { ...@@ -75,6 +75,7 @@ public class LoginController {
@RequestMapping(method = RequestMethod.GET, value = "/doLogin") @RequestMapping(method = RequestMethod.GET, value = "/doLogin")
public ModelAndView doLogin(@RequestParam("type") String type, HttpServletRequest request, HttpServletResponse response) public ModelAndView doLogin(@RequestParam("type") String type, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException { throws IOException, ServletException {
request.getSession().setAttribute("ars-referer", request.getHeader("referer"));
if("cas".equals(type)) { if("cas".equals(type)) {
casEntryPoint.commence(request, response, null); casEntryPoint.commence(request, response, null);
} else if("twitter".equals(type)) { } else if("twitter".equals(type)) {
......
...@@ -124,9 +124,8 @@ ...@@ -124,9 +124,8 @@
</constructor-arg> </constructor-arg>
</bean> </bean>
<bean id="successHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler" <bean id="successHandler" class="de.thm.arsnova.LoginAuthenticationSucessHandler"
p:alwaysUseDefaultTargetUrl="false" p:targetUrl="#auth/checkLogin"/>
p:defaultTargetUrl="/#auth/checkLogin"/>
<bean id="failureHandler" <bean id="failureHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"> class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment