if (request.getSession().getAttribute(WebKeys.REDIRECT_AFTER_LOGIN) != null) {
String redir = (String) request.getSession().getAttribute(WebKeys.REDIRECT_AFTER_LOGIN);
request.removeAttribute(WebKeys.REDIRECT_AFTER_LOGIN);
Logger.debug(this.getClass(), "redirecting after account creation: " + redir);
ActionForward af = new ActionForward(SecurityUtils.stripReferer(request, redir));
af.setRedirect(true);
return af;
}
ActionMessages msg = new ActionMessages();
msg.add(Globals.MESSAGE_KEY, new ActionMessage("message.Login.Successful"));
request.setAttribute(Globals.MESSAGE_KEY, msg);
ActionForward af = new ActionForward(SecurityUtils.stripReferer(request, referrer));
af.setRedirect(true);
return af;
}
else if (isUserInactive(form, request)) {
return mapping.findForward("resendActivationPage");
}
Logger.debug(this, "Failed login redirecting to: " + referrer);
ActionErrors errors = new ActionErrors();
errors.add(Globals.ERROR_KEY, new ActionMessage("errors.password.mismatch"));
request.getSession().setAttribute(Globals.ERROR_KEY, errors);
if(referrer != null && !referrer.equals("/")) {
ActionForward af = new ActionForward(SecurityUtils.stripReferer(request, referrer));
af.setRedirect(true);
return af;
} else {
if (!Config.getBooleanProperty("USE_CHALLENGE_QUESTION")) {
if(referrer != null && !referrer.equals("/")) {
ActionForward af = new ActionForward(SecurityUtils.stripReferer(request, referrer));
af.setRedirect(true);
return af;
} else
return mapping.findForward("loginPage");
} else {
User user = null;
Company company = PublicCompanyFactory.getDefaultCompany();
if (company.getAuthType().equals(Company.AUTH_TYPE_EA)) {
user = APILocator.getUserAPI().loadByUserByEmail(form.getUserName().toLowerCase(), APILocator.getUserAPI().getSystemUser(), false);
} else {
user = APILocator.getUserAPI().loadUserById(form.getUserName().toLowerCase(),APILocator.getUserAPI().getSystemUser(),false);
}
ActionForward af = new ActionForward(SecurityUtils.stripReferer(request, mapping.findForward("challengeQuestionPage").getPath() + "?emailAddress=" + user.getEmailAddress()));
return af;
}
}
} catch (NoSuchUserException e) {
Logger.debug(this, "Failed - User does not exist - login redirecting to: loginPage");
ActionErrors errors = new ActionErrors();
errors.add(Globals.ERROR_KEY, new ActionMessage("errors.user.not.exist"));
request.setAttribute(Globals.ERROR_KEY, errors);
//return to login page showing message the user doesn't exist
if(referrer != null && !referrer.equals("/")) {
ActionForward af = new ActionForward(SecurityUtils.stripReferer(request, referrer));
af.setRedirect(true);
return af;
} else
return mapping.findForward("loginPage");
}