You need to sign in or sign up before continuing.
[JITERA] Implement User Creation in UserServiceImpl
Created by: chi-jitera
Overview
This pull request implements the user creation functionality in the UserServiceImpl class of the authentication service. It ensures that new users can be created while checking for existing usernames and securely storing passwords.
Changes
-
User Existence Check:
- The method
create(User user)checks if a user with the same username already exists in the repository. If the user exists, it throws anIllegalArgumentExceptionto prevent duplicate entries.
- The method
-
Password Encoding:
- The user's password is encoded using
BCryptPasswordEncoderbefore saving it to the repository. This ensures that passwords are stored securely.
- The user's password is encoded using
-
User Saving:
- After encoding the password, the new user is saved to the repository.
-
Logging:
- A log statement is added to indicate that a new user has been created, which helps in tracking user creation events.
This implementation follows best practices for user management and enhances the security of user data.