@@ -209,23 +209,8 @@ public JWTDTO loginWithOAuth2(String code) {
209
209
@ SuppressWarnings ("unchecked" )
210
210
Map <String , Object > kakaoAccount = (Map <String , Object >) userInfo .get ("kakao_account" );
211
211
212
- String name = null ;
213
- String nickname = null ;
214
- if (properties != null ) {
215
- name = (String ) properties .get ("nickname" );
216
- }
217
- if (name == null ) {
218
- name = "카카오사용자" ;
219
- }
220
-
221
- if (nickname == null ) {
222
- nickname = randomNickname ();
223
- }
224
-
225
- String email = null ;
226
- if (kakaoAccount != null ) {
227
- email = (String ) kakaoAccount .get ("email" );
228
- }
212
+ String name = (properties != null ) ? (String ) properties .get ("nickname" ) : "카카오사용자" ;
213
+ String email = (kakaoAccount != null ) ? (String ) kakaoAccount .get ("email" ) : null ;
229
214
if (email == null ) {
230
215
throw new RuntimeException ("사용자 이메일을 가져올 수 없습니다." );
231
216
}
@@ -234,6 +219,8 @@ public JWTDTO loginWithOAuth2(String code) {
234
219
235
220
boolean isNewUser = false ;
236
221
if (userEntity == null ) {
222
+ // 새 유저일 때만 랜덤 닉네임 생성
223
+ String nickname = randomNickname ();
237
224
userEntity = UserEntity .builder ()
238
225
.uid (uid )
239
226
.nickname (nickname )
@@ -245,8 +232,8 @@ public JWTDTO loginWithOAuth2(String code) {
245
232
userRepository .save (userEntity );
246
233
isNewUser = true ;
247
234
} else {
235
+ // 기존 유저일 경우, 닉네임 변경 없이 다른 정보만 업데이트
248
236
userEntity .setName (name );
249
- userEntity .setNickname (nickname );
250
237
userEntity .setEmail (email );
251
238
userRepository .save (userEntity );
252
239
}
0 commit comments