NIHVIVO-1566 Display a welcome message for anyone who logs in.

This commit is contained in:
jeb228 2011-01-14 19:21:37 +00:00
parent a1238584fa
commit bf48d5d616

View file

@ -16,6 +16,7 @@ import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage;
import edu.cornell.mannlib.vitro.webapp.beans.User;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
@ -68,14 +69,14 @@ public class LoginRedirector {
}
public void redirectLoggedInUser() throws IOException {
DisplayMessage.setMessage(request, assembleWelcomeMessage());
try {
if (isSelfEditorWithIndividual()) {
log.debug("Going to Individual home page.");
response.sendRedirect(getAssociatedIndividualHomePage());
} else if (isMerelySelfEditor()) {
log.debug("User not recognized. Going to application home.");
DisplayMessage.setMessage(request, "You have logged in, "
+ "but the system contains no profile for you.");
response.sendRedirect(getApplicationHomePageUrl());
} else {
if (isLoginPage(afterLoginPage)) {
@ -96,6 +97,33 @@ public class LoginRedirector {
}
}
private String assembleWelcomeMessage() {
if (isMerelySelfEditor() && !isSelfEditorWithIndividual()) {
// A special message for unrecognized self-editors:
return "You have logged in, "
+ "but the system contains no profile for you.";
}
LoginStatusBean bean = LoginStatusBean.getBean(request);
Authenticator auth = Authenticator.getInstance(request);
User user = auth.getUserByUsername(bean.getUsername());
String backString = "";
String greeting = bean.getUsername();
if (user != null) {
if (user.getLoginCount() > 1) {
backString = " back";
}
String name = user.getFirstName();
if ((name != null) && (name.length() > 0)) {
greeting = name;
}
}
return "Welcome" + backString + ", " + greeting;
}
public void redirectCancellingUser() throws IOException {
try {
if (isLoginPage(afterLoginPage)) {