Revert "Bugfix for redirecting user to home page after login (#221)"
This reverts commit 2ad521e9da
.
This commit is contained in:
parent
2ad521e9da
commit
def81c9013
1 changed files with 25 additions and 10 deletions
|
@ -23,7 +23,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
|
||||
/**
|
||||
* A user has just completed the login process. What page do we direct them to?
|
||||
|
@ -77,7 +76,7 @@ public class LoginRedirector {
|
|||
|
||||
if (!canSeeSiteAdminPage()) {
|
||||
log.debug("User not recognized. Going to application home.");
|
||||
return UrlBuilder.getHomeUrl();
|
||||
return getApplicationHomePageUrl();
|
||||
}
|
||||
|
||||
if (isLoginPage(afterLoginPage)) {
|
||||
|
@ -88,20 +87,20 @@ public class LoginRedirector {
|
|||
return afterLoginPage;
|
||||
} else {
|
||||
log.debug("Don't know what to do. Go home.");
|
||||
return UrlBuilder.getHomeUrl();
|
||||
return getApplicationHomePageUrl();
|
||||
}
|
||||
}
|
||||
|
||||
public String getRedirectionUriForCancellingUser() {
|
||||
if (isLoginPage(afterLoginPage)) {
|
||||
log.debug("Coming from /login. Going to home.");
|
||||
return UrlBuilder.getHomeUrl();
|
||||
return getApplicationHomePageUrl();
|
||||
} else if (null != afterLoginPage) {
|
||||
log.debug("Returning to requested page: " + afterLoginPage);
|
||||
return afterLoginPage;
|
||||
} else {
|
||||
log.debug("Don't know what to do. Go home.");
|
||||
return UrlBuilder.getHomeUrl();
|
||||
return getApplicationHomePageUrl();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,12 +108,10 @@ public class LoginRedirector {
|
|||
throws IOException {
|
||||
try {
|
||||
DisplayMessage.setMessage(request, assembleWelcomeMessage());
|
||||
String redirectUrl = getRedirectionUriForLoggedInUser();
|
||||
log.debug("Sending redirect to path: " + redirectUrl);
|
||||
response.sendRedirect(redirectUrl);
|
||||
response.sendRedirect(getRedirectionUriForLoggedInUser());
|
||||
} catch (IOException e) {
|
||||
log.debug("Problem with re-direction", e);
|
||||
response.sendRedirect(UrlBuilder.getHomeUrl());
|
||||
response.sendRedirect(getApplicationHomePageUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +143,7 @@ public class LoginRedirector {
|
|||
response.sendRedirect(getRedirectionUriForCancellingUser());
|
||||
} catch (IOException e) {
|
||||
log.debug("Problem with re-direction", e);
|
||||
response.sendRedirect(UrlBuilder.getHomeUrl());
|
||||
response.sendRedirect(getApplicationHomePageUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,4 +174,22 @@ public class LoginRedirector {
|
|||
throw new IllegalStateException("No UTF-8 encoding? Really?", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
String contextRedirect = (String) session.getServletContext()
|
||||
.getAttribute("postLoginRequest");
|
||||
if (contextRedirect != null) {
|
||||
if (contextRedirect.indexOf(":") == -1) {
|
||||
return request.getContextPath() + contextRedirect;
|
||||
} else {
|
||||
return contextRedirect;
|
||||
}
|
||||
}
|
||||
return request.getContextPath();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue