User Registration Flow - Sequence Diagram #28
poksyy
started this conversation in
Show and tell
Replies: 1 comment
-
Implementation issue #18 . |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This discussion provides a detailed sequence diagram of the user registration process in our system. The registration process ensures that users are properly validated, stored in the database, and receive a JWT token for authentication.
1️⃣ User submits a registration request
A user initiates the registration process by sending a POST /api/auth/register request with:
2️⃣ AuthController receives the request and validates the input data
The request first reaches AuthController, which serves as the entry point for authentication.
The request body is mapped to a DTO (UserRegisterRequest) that includes annotations like @notblank and @Email to validate fields.
3️⃣ UserService checks if the user already exists and hashes the password
The business logic of user registration happens in UserService.
It first checks if a user with the given email or username already exists by querying the database through UserRepository.
If the user does not exist, the password is hashed using BCryptPasswordEncoder to prevent storing raw passwords.
4️⃣ UserRepository saves the new user to the database
Once validation and password hashing are complete, UserRepository (which extends JpaRepository) saves the new user entity in the database.
This step persists the user’s information permanently.
5️⃣ JwtService generates a JWT token for authentication
After successfully registering the user, we need to authenticate them immediately.
JwtService generates a JWT token, which includes user details and an expiration time.
This token will be required for subsequent API requests to verify the user’s identity.
6️⃣ Response is sent back to the user with the generated token
The AuthController returns a response containing:
The frontend or mobile app can now store this token and include it in Authorization headers for future requests.
Beta Was this translation helpful? Give feedback.
All reactions