Return 401 for auth failures and log verify
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s

This commit is contained in:
androidlover5842
2026-01-26 21:36:22 +05:30
parent 7ec8d6d350
commit 2c337b8709
2 changed files with 10 additions and 0 deletions

View File

@@ -80,10 +80,12 @@ class Auth(
val decoded = try {
FirebaseAuth.getInstance().verifyIdToken(token)
} catch (ex: Exception) {
logger.warn("Auth verify failed: {}", ex.message)
throw ResponseStatusException(HttpStatus.UNAUTHORIZED, "Invalid token")
}
val user = appUserRepo.findByFirebaseUid(decoded.uid)
?: throw ResponseStatusException(HttpStatus.UNAUTHORIZED, "User not found")
logger.info("Auth verify resolved uid={}, userId={}", decoded.uid, user.id)
return MyPrincipal(
userId = user.id ?: throw ResponseStatusException(HttpStatus.UNAUTHORIZED, "User id missing"),
firebaseUid = decoded.uid