Example #1
0
 @Override
 public boolean checkPasswords(MessageManager message, User user, int password) {
   if (user.getPassword() == password) {
     return true;
   }
   message.addMessage(MSG_PASSWORD);
   return false;
 }
Example #2
0
 @Override
 public boolean login(MessageManager message, User user) {
   if (user == null) {
     LOG.warn("User is null");
     return false;
   }
   int password = user.getPassword();
   try {
     user = userDao.findByEmail(user.getEmail());
     if (user == null || user.getPassword() != password) {
       message.addMessage(MSG_ICORRECT);
       return false;
     }
   } catch (DatabaseException e) {
     LOG.error("Login failed", e);
     message.addMessage(MSG_LOGIN);
     return false;
   }
   return true;
 }
Example #3
0
 @Override
 public boolean register(MessageManager message, User user) {
   if (user == null) {
     LOG.warn("User is null");
     return false;
   }
   if (isRegistered(user.getEmail())) {
     message.addMessage(MSG_EMAIL);
     return false;
   }
   try {
     userDao.save(user);
   } catch (DatabaseException e) {
     LOG.error("Register failed", e);
     message.addMessage(MSG_REGISTER);
     return false;
   }
   return true;
 }