Class UserRegister

java.lang.Object
application.user.UserRegister

public class UserRegister extends Object
The UserRegister class is responsible for handling the user registration process. It ensures that the provided user details meet the necessary criteria and that the username and email are not already in use. It also hashes the user's password before saving the user information into the repository.
  • Constructor Details

    • UserRegister

      public UserRegister(PasswordHasher hasher, UserRepository repo)
      Constructs a UserRegister instance responsible for handling the user registration process. It ensures user details meet validation criteria, such as uniqueness of username and email, and hashes passwords before saving user information into the repository.
      Parameters:
      hasher - a PasswordHasher implementation used to hash user passwords.
      repo - a UserRepository implementation responsible for storing user data.
  • Method Details

    • execute

      public void execute(String username, String phoneNumber, String password, String email)
      Executes a user registration. Validation checks, checks if username or e-mail already exists. Hashes inputted password using PasswordHasher, that uses SHA256PasswordHasher. Creates user object, and inserts it into UserRepository using insert method.
      Parameters:
      username -
      phoneNumber -
      password -
      email -