Skip to content

Commit

Permalink
add :: user null 검사 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Umjiseung committed Apr 8, 2024
1 parent 07e14c2 commit 6bb5da8
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mindway.server.v2.domain.auth.service.impl;

import com.mindway.server.v2.domain.auth.RefreshToken;
import com.mindway.server.v2.domain.auth.exception.UserNotFoundException;
import com.mindway.server.v2.domain.auth.presentation.dto.request.SignInRequest;
import com.mindway.server.v2.domain.auth.presentation.dto.response.TokenResponse;
import com.mindway.server.v2.domain.auth.repository.RefreshRepository;
Expand All @@ -20,6 +21,7 @@
import org.springframework.beans.factory.annotation.Value;

import java.io.IOException;
import java.util.Objects;
import java.util.UUID;

@RequiredArgsConstructor
Expand Down Expand Up @@ -52,6 +54,9 @@ public TokenResponse execute(SignInRequest signInRequest) throws GAuthException{
User user = userRepository.findByEmail(userInfo.getEmail())
.orElseGet(() -> saveUser(userInfo));

if (user == null)
throw new UserNotFoundException();

TokenResponse tokenResponse = jwtProvider.generateTokenDto(user.getId());

saveRefreshToken(tokenResponse, user);
Expand Down Expand Up @@ -82,7 +87,6 @@ private User saveStudent(GAuthUserInfo gAuthUserInfo) {
.email(gAuthUserInfo.getEmail())
.name(gAuthUserInfo.getName())
.studentNum(new StudentNum(gAuthUserInfo.getGrade(), gAuthUserInfo.getClassNum(), gAuthUserInfo.getNum()))
.gauth_role(gAuthUserInfo.getRole())
.authority(Authority.ROLE_STUDENT)
.build();

Expand Down

0 comments on commit 6bb5da8

Please sign in to comment.