File tree Expand file tree Collapse file tree
backend/src/main/java/com/jobtracker/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313import org .slf4j .Logger ;
1414import org .slf4j .LoggerFactory ;
1515import org .springframework .security .authentication .BadCredentialsException ;
16+ import org .springframework .security .core .Authentication ;
17+ import org .springframework .security .core .context .SecurityContextHolder ;
1618import org .springframework .security .core .userdetails .UserDetails ;
1719import org .springframework .security .crypto .password .PasswordEncoder ;
1820import org .springframework .stereotype .Service ;
@@ -125,7 +127,9 @@ public MessageResponse resetPassword(ResetPasswordRequest request) {
125127 @ Transactional
126128 public MessageResponse logout (LogoutRequest request ) {
127129 refreshTokenService .revokeToken (request .refreshToken ());
128- log .info ("event=LOGOUT_SUCCESS" );
130+ Authentication auth = SecurityContextHolder .getContext ().getAuthentication ();
131+ String userId = (auth != null && auth .isAuthenticated ()) ? auth .getName () : "unknown" ;
132+ log .info ("event=LOGOUT_SUCCESS userId={}" , userId );
129133 return new MessageResponse ("Logged out successfully" );
130134 }
131135
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ services:
1414 SPRING_DATASOURCE_URL : jdbc:mariadb://mariadb:3306/jobtracker?createDatabaseIfNotExist=true&characterEncoding=UTF-8&useUnicode=true
1515 SPRING_DATASOURCE_USERNAME : root
1616 SPRING_DATASOURCE_PASSWORD : root
17+ # WARNING: Replace this secret before any production use. This value is for development only.
1718 JWT_SECRET : ChangeThisToAVeryLongSecretKeyForJWTTokensInDevelopment
1819 CORS_ALLOWED_ORIGINS : " http://localhost:3000,http://localhost:5173"
1920 depends_on :
You can’t perform that action at this time.
0 commit comments