TheKiranAcademy
### User Registration
1. **As a new user, I want to create an account so that I can access the
system.**
- **API Endpoint:** `POST /api/register`
- **Request Body:**
{
"firstName": "Rajesh",
"lastName": "Kumar",
"username": "rajesh_kumar",
"email": "[Link]@[Link]",
"password": "securePassword123",
"phoneNumber": "9876543210",
"address": "123 Main Street, Mumbai, India",
"dateOfBirth": "1990-01-01"
}
- **Acceptance Criteria:**
1. **Successful Registration:**
- Given valid user details, the API should create a new user account and
return a success response.
- The user should receive a confirmation message indicating successful
registration.
2. **Duplicate Username/Email:**
- If the `username` or `email` is already in use, the API should return
an error indicating that the username or email already exists.
3. **Validation Errors:**
- If any required fields are missing or invalid (e.g., invalid email format,
weak password), the API should return an error specifying which fields are
invalid.
4. **Password Security:**
- The API should ensure the password meets security requirements
(e.g., minimum length, complexity).
5. **Password Encryption:**
- The API should encrypt the password before saving it to the database.
- The encrypted password should be securely stored and cannot be
retrieved in plain text.
### User Login
2. **As a registered user, I want to log in so that I can access my
account.**
- **API Endpoint:** `POST /api/login`
- **Request Body:**
{
"usernameOrEmail": "[Link]@[Link]",
"password": "securePassword123"
}
- **Acceptance Criteria:**
1. **Successful Login:**
- Given valid credentials, the API should authenticate the user and
return a success response indicating that the login was successful.
- The response should include a message confirming successful login.
2. **Invalid Credentials:**
- If the `usernameOrEmail` or `password` is incorrect, the API should
return an error indicating that the credentials are invalid.
3. **Password Matching:**
- The API should compare the provided password with the encrypted
password stored in the database, ensuring that only the correct password
grants access.
All The Best