Skip to content

Commit

Permalink
소셜로그인 시에 강의평 이메일 인증 여부 false로 설정, 인증받을때 스누메일인지 체크 (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
asp345 authored Sep 22, 2024
1 parent 7eacbcf commit bbafc91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions core/src/main/kotlin/users/service/AuthService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface AuthService {

fun isValidEmail(email: String): Boolean

fun isValidSnuMail(email: String): Boolean

fun isMatchedPassword(
user: User,
password: String,
Expand Down Expand Up @@ -65,6 +67,8 @@ class AuthServiceImpl(

override fun isValidEmail(email: String) = email.matches(emailRegex)

override fun isValidSnuMail(email: String) = email.matches(emailRegex) && email.endsWith("@snu.ac.kr")

override fun isMatchedPassword(
user: User,
password: String,
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/kotlin/users/service/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class UserServiceImpl(
log.warn("facebook email is null: $oauth2UserResponse")
}

return signup(credential, oauth2UserResponse.email, oauth2UserResponse.isEmailVerified)
return signup(credential, oauth2UserResponse.email, false)
}

override suspend fun loginGoogle(socialLoginRequest: SocialLoginRequest): LoginResponse {
Expand All @@ -245,7 +245,7 @@ class UserServiceImpl(

val credential = authService.buildGoogleCredential(oauth2UserResponse)

return signup(credential, oauth2UserResponse.email, oauth2UserResponse.isEmailVerified)
return signup(credential, oauth2UserResponse.email, false)
}

override suspend fun loginKakao(socialLoginRequest: SocialLoginRequest): LoginResponse {
Expand All @@ -268,7 +268,7 @@ class UserServiceImpl(

val credential = authService.buildKakaoCredential(oauth2UserResponse)

return signup(credential, oauth2UserResponse.email, oauth2UserResponse.isEmailVerified)
return signup(credential, oauth2UserResponse.email, false)
}

private fun getSocialProvider(user: User): SocialProvider {
Expand Down Expand Up @@ -326,7 +326,7 @@ class UserServiceImpl(
email: String,
) {
if (user.isEmailVerified == true) throw EmailAlreadyVerifiedException
if (!authService.isValidEmail(email)) throw InvalidEmailException
if (!authService.isValidSnuMail(email)) throw InvalidEmailException
if (userRepository.existsByEmailAndIsEmailVerifiedTrueAndActiveTrue(email)) throw DuplicateEmailException(getSocialProvider(user))
val key = VERIFICATION_CODE_PREFIX + user.id
val code = (Math.random() * 1000000).toInt().toString().padStart(6, '0')
Expand Down

0 comments on commit bbafc91

Please sign in to comment.