}
// Extract attributes we will need
HttpSession session = request.getSession();
MessageResources messages = getResources(request);
LogonForm logonForm = (LogonForm) form;
User user = new User();
ActionErrors errors = new ActionErrors();
String username = logonForm.getUsername();
String password = logonForm.getPassword();
UserDAO userDAO = UserDAO.getInstance();
try {
user = userDAO.getUser(username, password);
user.setIp(request.getRemoteAddr());
if (user.getStatus() == 0) {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("forum.LOG_FAIL",
new Object[] {
response.encodeURL("showFogotPass.do?uid=" +
username)
}));
JGossipLog.audit(
LogLevel.WARN,
user,
messages.getMessage("logs.LOG2")+" \""+username+"\"",
session);
} else {
session.setAttribute(IConst.SESSION.USER_KEY, user);
session.removeAttribute(IConst.SESSION.GROUPS_KEY);
log(request, "logs.LOG1");
}
} catch (SQLException sqle) {
getServlet().log("Connection.process", sqle);
throw new SystemException(sqle);
}
// Report any errors we have discovered back to the original form
if (!errors.isEmpty()) {
saveErrors(request, errors);
return (mapping.getInputForward());
}
if (IConst.VALUES.TRUE.equals(Configurator.getInstance().get(IConst.CONFIG.ENABLE_AUTO_LOGIN))) {
//set autolog cookies if needed...
if (user.getSettings().isAutologin()) {
Cookie userCookie = new Cookie(IConst.COOKIE.USER_COOKIE,
user.getName() + "*" + user.getPassword());
userCookie.setMaxAge(IConst.COOKIE.SECONDS_PER_YEAR);
((HttpServletResponse) response).addCookie(userCookie);
}
}
// Remove the obsolete form bean
if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope())) {
request.removeAttribute(mapping.getAttribute());
} else {
session.removeAttribute(mapping.getAttribute());
}
}
// Forward control to the specified success URI
String redirectUri = logonForm.getRedirectUri();
if ((redirectUri != null) && !redirectUri.equals("")) {
return (new ActionForward(redirectUri, true));
}