-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f8520c
commit 55d45f5
Showing
7 changed files
with
79 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
src/main/kotlin/com/hero/alignlab/domain/dev/resource/DevOAuthResource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 7 additions & 12 deletions
19
src/main/kotlin/com/hero/alignlab/domain/user/application/CredentialUserInfoService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,28 @@ | ||
package com.hero.alignlab.domain.user.application | ||
|
||
import com.hero.alignlab.common.encrypt.EncryptData | ||
import com.hero.alignlab.common.encrypt.Encryptor | ||
import com.hero.alignlab.domain.user.domain.CredentialUserInfo | ||
import com.hero.alignlab.domain.user.infrastructure.CredentialUserInfoRepository | ||
import com.hero.alignlab.exception.ErrorCode | ||
import com.hero.alignlab.exception.NotFoundException | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
class CredentialUserInfoService( | ||
private val credentialUserInfoRepository: CredentialUserInfoRepository, | ||
private val encryptor: Encryptor, | ||
) { | ||
suspend fun existsByUsername(username: String): Boolean { | ||
return withContext(Dispatchers.IO) { | ||
credentialUserInfoRepository.existsByUsername(username) | ||
existsByUsernameSync(username) | ||
} | ||
} | ||
|
||
fun save(credentialUserInfo: CredentialUserInfo): CredentialUserInfo { | ||
return credentialUserInfoRepository.save(credentialUserInfo) | ||
private fun existsByUsernameSync(username: String): Boolean { | ||
return credentialUserInfoRepository.existsByUsername(username) | ||
} | ||
|
||
suspend fun findByUsernameAndPassword(username: String, password: String): CredentialUserInfo { | ||
return withContext(Dispatchers.IO) { | ||
credentialUserInfoRepository.findByUsernameAndPassword(username, EncryptData.enc(password, encryptor)) | ||
} ?: throw NotFoundException(ErrorCode.NOT_FOUND_USER_ERROR) | ||
@Transactional | ||
fun saveSync(credentialUserInfo: CredentialUserInfo): CredentialUserInfo { | ||
return credentialUserInfoRepository.save(credentialUserInfo) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters