@@ -119,8 +119,14 @@ public ResponseEntity<LoginResponse> login(@RequestBody LoginRequest loginReques
119119 }
120120
121121 // Update lastLoginAt
122- user .setLastLoginAt (OffsetDateTime .now ());
123- userRepository .save (user );
122+ OffsetDateTime loginTime = OffsetDateTime .now ();
123+ System .out .println ("=== LOGIN DEBUG ===" );
124+ System .out .println ("Before update - lastLoginAt: " + user .getLastLoginAt ());
125+ user .setLastLoginAt (loginTime );
126+ System .out .println ("Setting lastLoginAt in database to: " + loginTime );
127+ UserEntity savedUser = userRepository .save (user );
128+ System .out .println ("After save - lastLoginAt: " + savedUser .getLastLoginAt ());
129+ System .out .println ("=== END LOGIN DEBUG ===" );
124130
125131 // Generate JWT
126132 SecretKey key = Keys .hmacShaKeyFor (JWT_SECRET .getBytes ());
@@ -145,6 +151,10 @@ public ResponseEntity<User> getProfile() {
145151
146152 UserEntity userEntity = userOpt .get ();
147153
154+ System .out .println ("=== PROFILE DEBUG ===" );
155+ System .out .println ("Retrieved from DB - lastLoginAt: " + userEntity .getLastLoginAt ());
156+ System .out .println ("=== END PROFILE DEBUG ===" );
157+
148158 // Map to API User model
149159 User user = new User ()
150160 .id (userEntity .getId ())
@@ -156,6 +166,15 @@ public ResponseEntity<User> getProfile() {
156166 .createdAt (userEntity .getCreatedAt ())
157167 .updatedAt (userEntity .getUpdatedAt ());
158168
169+ // Handle lastLoginAt properly using the correct method
170+ if (userEntity .getLastLoginAt () != null ) {
171+ // Use the method that takes OffsetDateTime directly
172+ user .lastLoginAt (userEntity .getLastLoginAt ());
173+ System .out .println ("Setting lastLoginAt to: " + userEntity .getLastLoginAt ());
174+ } else {
175+ System .out .println ("lastLoginAt is null in entity" );
176+ }
177+
159178 return ResponseEntity .ok (user );
160179 }
161180
0 commit comments