Authentication Guide
TaskFlow uses robust JWT (JSON Web Token) authentication to secure endpoints.
Auth Flow
-
Login: User sends
emailandpasswordto/auth/login.- Server validates credentials (bcrypt).
- Server signs a JWT containing the user ID and Roles.
- Server returns the
token.
-
Authenticated Requests: Client sends the token in the
Authorizationheader. -
Role Verification: specific endpoints (like
create-user) check the JWT payload forROLE_ADMIN.
Error Handling
401 Unauthorized: Token is missing, invalid, or expired.403 Forbidden: Token is valid, but the user lacks the required role (e.g., standard user trying to access admin route).