Skip to content

Commit

Permalink
[#7] Exception Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jun108059 committed Oct 7, 2021
1 parent 05ad8f4 commit b389511
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.teamnexters.lazy.api.config.auth;
import com.teamnexters.lazy.api.config.auth.dto.OAuthAttributes;
import com.teamnexters.lazy.api.config.auth.dto.SessionUser;
import com.teamnexters.lazy.common.domain.member.Member;
import com.teamnexters.lazy.common.domain.member.MemberRepository;
import lombok.RequiredArgsConstructor;
Expand All @@ -14,7 +13,6 @@
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.Collections;

@Slf4j
Expand All @@ -36,7 +34,7 @@ public class CustomOAuth2UserService implements OAuth2UserService<OAuth2UserRequ
*
* @param userRequest OAuth 프로바이더에서 내려준 정보
* @return OAuth User
* @throws OAuth2AuthenticationException
* @throws OAuth2AuthenticationException OAuth2 Exception
*/
@Override
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {
Expand Down Expand Up @@ -70,6 +68,8 @@ private Member saveOrUpdate(OAuthAttributes attributes) {
Member user = memberRepository.findByEmail(attributes.getEmail())
.map(entity -> entity.update(attributes.getName(),attributes.getPicture()))
.orElse(attributes.toEntity());
log.debug(">>> user Info : {}", user);

// DB에 저장 후 사용자 객체 반환
return memberRepository.save(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public enum ErrorCode {
TOKEN_IS_EXPIRED(407, "C007", "토큰이 만료되었습니다."),

INTERNAL_SERVER_ERROR(500, "C008", "서버 내부 에러입니다."),
EXTERNAL_SERVER_ERROR(501, "C009", "외부 API 통신 에러입니다."),

// Member
EMAIL_DUPLICATION(410, "M001", "이미 등록된 이메일입니다."),
NICKNAME_DUPLICATION(411, "M002", "이미 등록된 닉네임입니다."),
LOGIN_INPUT_INVALID(412, "M003", "잘못된 로그인 요청 값입니다."),
OAUTH_PROVIDER_NOT_SUPPORT(413, "M004", "제공되지 않는 소셜로그인입니다."),
MEMBER_NOT_FOUND(414, "M005", "존재하지 않는 회원입니다."),

// Habit
HABIT_DUPLICATION(421, "H001", "이미 등록된 습관입니다.");
Expand Down

0 comments on commit b389511

Please sign in to comment.