* @return the User that matches the passed values, or null if non was found
* @throws ServiceException if a database error occured
*/
@Override
public User doLogin(String email, String password) {
User user = null;
try {
begin();
user = getUserDAO().userValid(email, password, getConnection());
commit();
} catch (DAOException e) {
throw new ServiceException("Error in retrieving user with email and password", e);
} catch (SQLException e) {
throw new ServiceException("Error in retrieving user with email and password", e);
} finally {
closeConnection();
}
if (user == null)
return null;
user.setLastLoginDate(new Date());
try {
updateUser(user, "s last login date");
} catch (ServiceException e) {
logger.error(
"Failed to set lastlogindate for user " + user.getId(), e);
}
jsfUtil.userLoggedIn(user);
return user;
}