File tree Expand file tree Collapse file tree
src/main/java/com/linku/backend/domain/user Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,4 +81,10 @@ public String getGoogleId() {
8181
8282 return gMail .substring (0 , atIndex );
8383 }
84+
85+ public void updatePictureIfEmpty (String picture ) {
86+ if (this .picture == null || this .picture .isBlank ()) {
87+ this .picture = picture ;
88+ }
89+ }
8490}
Original file line number Diff line number Diff line change @@ -27,7 +27,12 @@ public class UserService {
2727 @ Transactional
2828 public User findOrCreateUser (GoogleUserInfo userInfo ) {
2929 Optional <User > optionalUser = userRepository .findByProviderId (userInfo .sub ());
30- return optionalUser .orElseGet (() -> userRepository .save (User .guest (userInfo )));
30+ if (optionalUser .isPresent ()) {
31+ User existingUser = optionalUser .get ();
32+ existingUser .updatePictureIfEmpty (userInfo .picture ());
33+ return existingUser ;
34+ }
35+ return userRepository .save (User .guest (userInfo ));
3136 }
3237
3338 public User getUserById (Long UserId ) {
You can’t perform that action at this time.
0 commit comments