File tree 1 file changed +31
-0
lines changed
src/main/kotlin/entry/dsm/gitauth/equusgithubauth/global/oauth/service
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments