Enhance authentication logging and update MyBatis configuration

This commit is contained in:
zyh
2025-08-24 16:52:20 +08:00
parent 51d6319121
commit bc1f10381a
20 changed files with 122 additions and 36 deletions

View File

@@ -4,6 +4,8 @@ import com.gameplatform.server.model.dto.auth.LoginRequest;
import com.gameplatform.server.model.dto.auth.LoginResponse;
import com.gameplatform.server.security.JwtService;
import io.jsonwebtoken.Claims;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.validation.Valid;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@@ -13,6 +15,7 @@ import reactor.core.publisher.Mono;
@RestController
@RequestMapping("/api/auth")
public class AuthController {
private static final Logger log = LoggerFactory.getLogger(AuthController.class);
private final com.gameplatform.server.service.auth.AuthService authService;
private final JwtService jwtService;
@@ -25,6 +28,7 @@ public class AuthController {
@PostMapping("/login")
@ResponseStatus(HttpStatus.OK)
public Mono<LoginResponse> login(@Valid @RequestBody LoginRequest req) {
log.info("/api/auth/login called username={}", req.getUsername());
return authService.login(req);
}
@@ -32,6 +36,7 @@ public class AuthController {
public Mono<Object> me(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorization) {
String token = authorization != null && authorization.startsWith("Bearer ") ? authorization.substring(7) : authorization;
return Mono.fromCallable(() -> jwtService.parse(token))
.doOnError(e -> log.warn("/api/auth/me parse token error: {}", e.toString()))
.map(this::claimsToMe);
}