bilhej/backend
Joakim Mörling 3d4a6daee9 feat: add login endpoint with JWT authentication
Add POST /api/auth/login endpoint that authenticates users by email and
password, returning a JWT token on success. Also fixes a critical bug
where expired or malformed JWT tokens in the Authorization header caused
unhandled exceptions, crashing requests to all endpoints including public
ones like registration.

Changes:
- Add AuthController.login() endpoint with LoginRequest DTO
- Add UserService.authenticate() that validates credentials and throws
  InvalidCredentialsException on failure
- Add InvalidCredentialsException and GlobalExceptionHandler handler
  that maps it to 401 with Swedish error message
- Fix JwtAuthenticationFilter to catch JwtException (expired, malformed)
  and pass through without crashing — the filter now acts as a graceful
  enricher rather than a gatekeeper
- Add 5 controller tests for login endpoint (success, 401, validation)
- Add 4 service tests for authenticate() (success, email not found,
  password mismatch, email normalization)
- Add 2 filter tests for expired and malformed token pass-through
2026-05-13 19:16:19 +02:00
..
src feat: add login endpoint with JWT authentication 2026-05-13 19:16:19 +02:00
.gitattributes feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
.gitignore feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
build.gradle chore: add JWT secret env config, jjwt deps, and docker-compose prod fixes 2026-05-01 17:38:03 +02:00
gradlew.bat feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00