diff --git a/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/UserCoreService.kt b/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/UserCoreService.kt index a554243..481d82d 100644 --- a/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/UserCoreService.kt +++ b/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/UserCoreService.kt @@ -9,6 +9,7 @@ import ru.touchin.auth.core.user.services.dto.NewAnonymousUser import ru.touchin.auth.core.user.services.dto.NewUser import ru.touchin.auth.core.user.services.dto.UserLogin import ru.touchin.auth.core.user.services.dto.UserLogout +import ru.touchin.auth.core.user.services.dto.UserSetPassword import ru.touchin.auth.core.user.services.dto.UserUpdatePassword interface UserCoreService { @@ -21,6 +22,7 @@ interface UserCoreService { fun login(userLogin: UserLogin): User fun logout(userLogout: UserLogout) fun updatePassword(update: UserUpdatePassword) + fun setPassword(userSetPassword: UserSetPassword) fun addScopes(addUserScopes: AddUserScopes) } diff --git a/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/UserCoreServiceImpl.kt b/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/UserCoreServiceImpl.kt index 776e576..514412c 100644 --- a/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/UserCoreServiceImpl.kt +++ b/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/UserCoreServiceImpl.kt @@ -35,6 +35,7 @@ import ru.touchin.auth.core.user.services.dto.NewAnonymousUser import ru.touchin.auth.core.user.services.dto.NewUser import ru.touchin.auth.core.user.services.dto.UserLogin import ru.touchin.auth.core.user.services.dto.UserLogout +import ru.touchin.auth.core.user.services.dto.UserSetPassword import ru.touchin.auth.core.user.services.dto.UserUpdatePassword @Service @@ -146,6 +147,15 @@ class UserCoreServiceImpl( }.also(userAccountRepository::save) } + @Transactional + override fun setPassword(userSetPassword: UserSetPassword) { + val userAccount = userAccountRepository.findByIdOrThrow(userSetPassword.userAccountId) + + userAccount.apply { + password = userSetPassword.newPassword.let(passwordEncoder::encode) + }.also(userAccountRepository::save) + } + @Transactional override fun addScopes(addUserScopes: AddUserScopes) { val user = userRepository.findByIdOrThrow(addUserScopes.userId) diff --git a/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/dto/UserSetPassword.kt b/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/dto/UserSetPassword.kt new file mode 100644 index 0000000..b8a33aa --- /dev/null +++ b/security-authorization-server-core/src/main/kotlin/ru/touchin/auth/core/user/services/dto/UserSetPassword.kt @@ -0,0 +1,8 @@ +package ru.touchin.auth.core.user.services.dto + +import java.util.* + +data class UserSetPassword( + val userAccountId: UUID, + val newPassword: String +)