Refactor logging in LoginController, simplify auth.service token validation, and remove debug logs from AppealComponent.

This commit is contained in:
akastijn 2025-08-05 23:22:12 +02:00
parent bdb38e5011
commit f67cb50f41
3 changed files with 18 additions and 18 deletions

View File

@ -93,6 +93,7 @@ public class LoginController implements LoginApi {
@Override
public ResponseEntity<UsernameDto> getUsername() {
log.debug("Loading username for logged in user");
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || !(authentication.getPrincipal() instanceof OAuth2ResourceServerProperties.Jwt)) {
@ -103,13 +104,14 @@ public class LoginController implements LoginApi {
UUID uuid;
try {
uuid = UUID.fromString(stringUuid);
log.debug("Loaded username for logged in user {}", uuid);
} catch (IllegalArgumentException e) {
return ResponseEntity.badRequest().build();
}
UsernameDto usernameDto = new UsernameDto();
usernameDto.setUsername(getUsername(uuid));
log.debug("Loaded username for logged in user {}", usernameDto.getUsername());
return ResponseEntity.ok(usernameDto);
}

View File

@ -164,9 +164,7 @@ export class AppealComponent implements OnInit, AfterViewInit {
public nextPage() {
if (this.currentPageIndex === this.totalPages.length - 1) {
console.log('Adding page');
this.totalPages.push(this.currentPageIndex + 1);
console.log(this.totalPages);
}
this.goToPage(this.currentPageIndex + 1);
}

View File

@ -72,9 +72,10 @@ export class AuthService {
*/
public checkAuthStatus(): boolean {
const jwt = this.getJwt();
if (jwt) {
if (!jwt) {
return false;
}
try {
// Check if token is expired
if (this.jwtHelper.isTokenExpired(jwt)) {
this.logout();
return false;
@ -89,7 +90,6 @@ export class AuthService {
} catch (e) {
this.logout();
}
}
return false;
}