LoginForm login = (LoginForm) getLoginRequest();
l.info("Processing Login Request from session "+req.getSession().getId());
Visitor v = login.getVistor();
Employee emp = null;
View resultView = null;
try {
emp= service.authenticateEmployee(login.getVistor().getEmail(), login.getPassword());
if (emp!= null) {
l.info("Login Successful for "+login.getVistor().getEmail());
v.setEmployeeAuthenticated(true);
v.setEmployee(emp);
v.setKnown(true);
req.getSession().setAttribute(SESSION_ATTRIBUTE_VISITOR,v);
login.setForm(FormName.LOGIN);
login.setSuccess(true);
}
else {
resultView = getLoginView("Invalid email or password. Please try again.", getMainAdminView());
}
} catch (Exception e) {
l.log(Level.INFO, "Failed authentication", e);
resultView = getLoginView("Invalid email or password. Please try again.", getMainAdminView());
}
if (v.isEmployeeAuthenticated()) try {
if (login.getRedirect() != null) {
resultView = new View();
resultView.setRedirectPath(login.getRedirect());
}