Skip to content

Commit 73506f7

Browse files
committed
feat : (#31) add googleOauthUserService
1 parent 985a611 commit 73506f7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package entry.dsm.gitauth.equusgithubauth.global.oauth.service
2+
3+
import entry.dsm.gitauth.equusgithubauth.domain.user.entity.User
4+
import entry.dsm.gitauth.equusgithubauth.domain.user.entity.enums.UserRole
5+
import entry.dsm.gitauth.equusgithubauth.domain.user.entity.repository.UserRepository
6+
import org.springframework.stereotype.Service
7+
8+
@Service
9+
class GoogleOauthUserService(
10+
private val userRepository: UserRepository
11+
) {
12+
fun findOrCreateOAuthUser(
13+
loginId: String,
14+
email: String,
15+
name: String,
16+
provider: String,
17+
providerId: String
18+
): User {
19+
return userRepository.findByLoginId(loginId) ?: run {
20+
User(
21+
loginId = loginId,
22+
email = email,
23+
password = "",
24+
name = name,
25+
provider = provider,
26+
providerId = providerId,
27+
role = UserRole.USER
28+
).also { userRepository.save(it) }
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)