Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Method that creates a new UserDefault and returns it
- *
- * @param name the user's name
- * @param email the user's email
- * @param uncryptedPassword the user's uncrypted password
- * @return the created User Default
- */
- public UserDefault newUserDefault(String name, String email, String uncryptedPassword) {
- return new UserDefault(name, email, uncryptedPassword);
- }
- /**
- * Method to add and validate a user if the user is valid it is then added
- * to the list
- *
- * @param user the user we are validating and adding
- * @param passwordUncrypted the user's password
- * @return true if the user was valid and added sucessfully
- */
- public boolean addUser(UserDefault user, String passwordUncrypted) {
- if (findUser(user.getEmail()) != null) {
- return false;
- }
- if (!user.validateUser(passwordUncrypted)) {
- return false;
- }
- return add(user);
- }
- }
- ///Diferente
- /**
- * Complete constructor for UserDafault
- * @param username The user's username
- * @param email the user's email
- * @param uncryptedPassword the user's uncrypted password
- */
- public UserDefault(String username , String email , String uncryptedPassword){
- this.username=username;
- this.email=email;
- this.password=new Password(uncryptedPassword);
- }
- /**
- * Method the validates the userDefault
- * @param uncryptedPassword the user's uncrypted password
- * @return true if inserted password was equal to user's pre-determined password
- */
- public boolean validateUser(String uncryptedPassword){
- return password.checkPassword(uncryptedPassword);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement