11package org.yapp.apis.auth.service
22
33import org.springframework.stereotype.Service
4+ import org.yapp.apis.auth.dto.TokenPair
45import org.yapp.apis.auth.dto.UserProfileResponse
56import org.yapp.apis.auth.exception.AuthErrorCode
67import org.yapp.apis.auth.exception.AuthException
@@ -32,7 +33,9 @@ class AuthServiceImpl(
3233 )
3334
3435 if (existingUser != null ) {
35- return generateTokenPair(existingUser.id!! )
36+ return generateTokenPair(
37+ existingUser.id ? : throw IllegalStateException (" Existing user id should not be null" )
38+ )
3639 }
3740
3841 userRepository.findByEmail(userInfo.email)?.let {
@@ -70,11 +73,10 @@ class AuthServiceImpl(
7073 tokenRepository.deleteRefreshToken(userId)
7174 }
7275
73- override fun getUserById (userId : Long ): User ? = null
76+ override fun getUserById (userId : Long ): User ? = userRepository.findById(userId)
7477
7578 override fun getUserProfile (userId : Long ): UserProfileResponse {
7679 val user = userRepository.findById(userId)
77-
7880 return UserProfileResponse (
7981 id = user.id!! ,
8082 email = user.email,
@@ -98,7 +100,10 @@ class AuthServiceImpl(
98100
99101 private fun getAuthStrategy (credentials : AuthCredentials ): AuthStrategy {
100102 return authStrategies.find { it.getProviderType() == credentials.getProviderType() }
101- ? : throw AuthException (AuthErrorCode .UNSUPPORTED_PROVIDER_TYPE , " Unsupported provider type: ${credentials.getProviderType()} " )
103+ ? : throw AuthException (
104+ AuthErrorCode .UNSUPPORTED_PROVIDER_TYPE ,
105+ " Unsupported provider type: ${credentials.getProviderType()} "
106+ )
102107 }
103108
104109 private fun generateTokenPair (userId : Long ): TokenPair {
0 commit comments