[VIVO-1736] - Bugfix for redirecting user to home page after login (#227)
* Add trailing slash to home page redirect if contextPath empty * Add redirect path to debug log * Remove outdated code comment
This commit is contained in:
parent
cd437a503e
commit
71ca39d597
1 changed files with 9 additions and 15 deletions
|
@ -108,7 +108,9 @@ public class LoginRedirector {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try {
|
try {
|
||||||
DisplayMessage.setMessage(request, assembleWelcomeMessage());
|
DisplayMessage.setMessage(request, assembleWelcomeMessage());
|
||||||
response.sendRedirect(getRedirectionUriForLoggedInUser());
|
String redirectUrl = getRedirectionUriForLoggedInUser();
|
||||||
|
log.debug("Sending redirect to path: " + redirectUrl);
|
||||||
|
response.sendRedirect(redirectUrl);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.debug("Problem with re-direction", e);
|
log.debug("Problem with re-direction", e);
|
||||||
response.sendRedirect(getApplicationHomePageUrl());
|
response.sendRedirect(getApplicationHomePageUrl());
|
||||||
|
@ -175,21 +177,13 @@ public class LoginRedirector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The application home page can be overridden by an attribute in the
|
|
||||||
* ServletContext. Further, it can either be an absolute URL, or it can be
|
|
||||||
* relative to the application. Weird.
|
|
||||||
*/
|
|
||||||
private String getApplicationHomePageUrl() {
|
private String getApplicationHomePageUrl() {
|
||||||
String contextRedirect = (String) session.getServletContext()
|
String contextPath = request.getContextPath();
|
||||||
.getAttribute("postLoginRequest");
|
if (contextPath.equals("")) {
|
||||||
if (contextRedirect != null) {
|
return "/";
|
||||||
if (contextRedirect.indexOf(":") == -1) {
|
|
||||||
return request.getContextPath() + contextRedirect;
|
|
||||||
} else {
|
|
||||||
return contextRedirect;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return contextPath;
|
||||||
}
|
}
|
||||||
return request.getContextPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue