Class AuthenticationService

java.lang.Object
com.mindstore.backend.service.AuthenticationService

@Service public class AuthenticationService extends Object
Service class for authentication functions
  • Constructor Details

    • AuthenticationService

      public AuthenticationService(UserRepository userRepository, org.springframework.security.authentication.AuthenticationManager authenticationManager, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder)
      Authentication Service class
      Parameters:
      userRepository - containing user functionalities, eg. for signup
      authenticationManager - manages authentication for the user
      passwordEncoder - encodes the user password
  • Method Details

    • signup

      public User signup(RegisterUserDto input)
      function: sign up a user
      Parameters:
      input - RegisterUSerDTO with name and password
      Returns:
      the saved User
    • authenticate

      public User authenticate(LoginUserDto input)
      function: used to authenticate a user, for example for the login by using authenticationManager
      Parameters:
      input - LoginUserDto
      Returns:
      User
    • findOrCreateUserByEmail

      public User findOrCreateUserByEmail(String email)
      function: search for a user by using the email if the user isn't found, create them.
      Parameters:
      email - of the user
      Returns:
      the User that was created