Example #1
0
 /**
  * Validates user
  *
  * @param user
  * @return
  */
 public static boolean validateUser(AppUser user) {
   if (user == null) {
     return false;
   }
   user.token = null;
   user.validated = true;
   user.update();
   return true;
 }
Example #2
0
 /**
  * Saves new user to database, user is checked for being null value, depending on userType, seller
  * doesn't have to authenticate email address.
  *
  * @param user <code>AppUser</code> type value of user
  * @param userType <code>String</code> type value of user type
  * @return <code>boolean</code> type value if user is successfully saved to database, false if not
  */
 public static boolean saveNewUser(AppUser user, String userType) {
   if (user != null) {
     user.hashPass();
     user.token = UUID.randomUUID().toString();
     user.androidToken = UUID.randomUUID().toString();
     if (Constants.USER_SELLER.equals(userType)) {
       user.userAccessLevel = UserAccessLevel.SELLER;
       user.validated = Constants.VALIDATED_USER;
     }
     try {
       user.save();
       return true;
     } catch (PersistenceException e) {
       ErrorLogger.createNewErrorLogger(
           "Failed to save user. Possible duplicate email entry.", e.getMessage());
       return false;
     }
   }
   return false;
 }