# Project Tasks List

## Task 1: Implement Backend User Authentication & Account Management [BACKEND] — TEST: FAIL
Set up the basic project structure and environment.

### 1.1 Define User Entity and Repository
- [x] Create `User` entity with fields: `id`, `username`, `email`, `passwordHash`, `createdAt`, `updatedAt`.
- [x] Create `UserRepository` for database interactions.

### 1.2 Implement User Registration
- [x] Create `RegisterRequest` DTO.
- [x] Create `AuthResponse` DTO.
- [x] Add registration method to `AuthController`.
- [x] Implement password hashing in `UserService`.
- [x] Save user to `UserRepository`.

### 1.3 Implement User Login
- [x] Create `LoginRequest` DTO.
- [x] Add login method to `AuthController`.
- [x] Validate user credentials in `UserService`.
- [x] Generate JWT token upon successful login in `UserService`.

### 1.4 Implement Password Reset Initiation
- [x] Create `PasswordResetRequest` DTO.
- [x] Add password reset initiation method to `AuthController`.
- [x] Generate a unique password reset token in `UserService`.
- [x] Store the reset token with an expiration time in the database.
- [x] Send password reset email to the user (placeholder for now).

### 1.5 Configure Security (JWT)
- [x] Configure Spring Security for JWT authentication.
- [x] Create `JwtAuthenticationFilter` to validate tokens.
- [x] Create `JwtTokenProvider` to generate and validate JWTs.

### 1.6 Database Schema Update
- [x] Update `schema.sql` or use JPA to generate/update user table schema.


## Task 2: Integrate Frontend with Backend Authentication [FRONTEND]
Connect the existing Angular Clarity frontend's login, registration, and password reset UIs to the new Spring Boot backend authentication endpoints. Ensure proper handling of JWT tokens for authenticated sessions.

### 2.1 Update API Service for Authentication
- [x] Create/update an authentication service to handle API calls for register, login, and password reset.
- [x] Implement methods for storing and retrieving JWT tokens.
### 2.2 Integrate Login Component
- [x] Modify the login component to use the authentication service.
- [x] Handle successful login (store token, redirect).
- [x] Display error messages for failed login.
### 2.3 Integrate Registration Component
- [x] Create `register-page` directory and `register-page.component.ts`, `register-page.component.html`, `register-page.component.scss` files.
- [x] Update `login.module.ts` to declare and import `RegisterPageComponent`.
- [x] Update `login-routing.module.ts` to add a route for `/register`.
- [x] Implement `RegisterPageComponent` to inject `AuthService`.
- [x] Implement the registration method in `RegisterPageComponent` to call `AuthService.register`.
- [x] Handle successful registration by redirecting to the login page.
- [x] Handle registration errors and display appropriate messages in `RegisterPageComponent`.
- [x] Create `register-page.component.html` to bind form fields and display error messages.

### 2.4 Integrate Password Reset Components
- [x] Locate and read the password reset initiation component files.
- [x] Update the password reset initiation component to inject `AuthService`.
- [x] Implement the password reset initiation method to call `AuthService.initiatePasswordReset`.
- [x] Handle successful initiation by displaying a success message.
- [x] Handle initiation errors and display appropriate messages.
- [x] Update the password reset initiation component's HTML to bind form fields and display error messages.

### 2.5 Implement JWT Interceptor
- [ ] Create `jwt.interceptor.ts` to attach JWT token to outgoing requests.
- [ ] Register the interceptor in `app.module.ts`.

### 2.6 Update Routing Guards
- [ ] Modify existing routing guards to check for JWT token validity.

### 2.7 Handle Token Expiration/Refresh
- [ ] Add logic to `AuthService` to handle token expiration.
- [ ] Implement token refresh mechanism (if applicable).

### 2.8 Display User-Specific Content
- [ ] Add a placeholder in a component to display user info if authenticated.

## Current Task Status
**Currently Working On:** Task 2.5 - Implement JWT Interceptor
**Next Task:** Task 2.6 - Update Routing Guards
**Completed Tasks:** Task 1 - Implement Backend User Authentication & Account Management [BACKEND], Task 2.1 - Update API Service for Authentication, Task 2.2 - Integrate Login Component, Task 2.3 - Integrate Registration Component, Task 2.4 - Integrate Password Reset Components

## Task Completion Guidelines
- Use `- [x]` to mark completed subtasks (to be added by Developer)
- Use `- [ ]` for pending subtasks (to be added by Developer)
- Update "Currently Working On" when starting a new subtask (to be managed by Developer)
- Update "Completed Tasks" when finishing a task (to be managed by Developer)
- Always maintain the hierarchical structure (Task → Subtask → Subtask items)
- **IMPORTANT: Do NOT add subtasks here. Only create main tasks. Subtasks will be added by the Developer agent.
