NIHVIVO-1566 Display a welcome message for anyone who logs in.
This commit is contained in:
parent
a1238584fa
commit
bf48d5d616
1 changed files with 30 additions and 2 deletions
|
@ -16,6 +16,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage;
|
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.Controllers;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
|
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
|
||||||
|
|
||||||
|
@ -68,14 +69,14 @@ public class LoginRedirector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void redirectLoggedInUser() throws IOException {
|
public void redirectLoggedInUser() throws IOException {
|
||||||
|
DisplayMessage.setMessage(request, assembleWelcomeMessage());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isSelfEditorWithIndividual()) {
|
if (isSelfEditorWithIndividual()) {
|
||||||
log.debug("Going to Individual home page.");
|
log.debug("Going to Individual home page.");
|
||||||
response.sendRedirect(getAssociatedIndividualHomePage());
|
response.sendRedirect(getAssociatedIndividualHomePage());
|
||||||
} else if (isMerelySelfEditor()) {
|
} else if (isMerelySelfEditor()) {
|
||||||
log.debug("User not recognized. Going to application home.");
|
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());
|
response.sendRedirect(getApplicationHomePageUrl());
|
||||||
} else {
|
} else {
|
||||||
if (isLoginPage(afterLoginPage)) {
|
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 {
|
public void redirectCancellingUser() throws IOException {
|
||||||
try {
|
try {
|
||||||
if (isLoginPage(afterLoginPage)) {
|
if (isLoginPage(afterLoginPage)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue