Refactor logging in LoginController, simplify auth.service token validation, and remove debug logs from AppealComponent.
This commit is contained in:
parent
bdb38e5011
commit
f67cb50f41
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user