|
|
@@ -143,6 +143,25 @@ public class UserService {
|
|
|
log.debug("Reset Password for User: {}", savedUser);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = RuntimeException.class)
|
|
|
+ public void resetGitlabPassword(String phone, String phoneCode, String password) {
|
|
|
+ checkPhoneMessageOrThrowError(phone, phoneCode);
|
|
|
+
|
|
|
+ User user = userRepository
|
|
|
+ .findByPhone(phone)
|
|
|
+ .<UsernameNotFoundException>orElseThrow(() -> {
|
|
|
+ // TODO: use customException
|
|
|
+ throw new UsernameNotFoundException("找不到手机用户[" + phone + "]");
|
|
|
+ });
|
|
|
+ User savedUser = userRepository.save(user);
|
|
|
+ try {
|
|
|
+ gitlabService.changePassword(Math.toIntExact(savedUser.getId()),password);
|
|
|
+ } catch (SeecoderGitlabException e) {
|
|
|
+ throw new CustomErrorException("gitlab密码重置失败,请联系管理人员!");
|
|
|
+ }
|
|
|
+ log.debug("Reset Password for User: {}", savedUser);
|
|
|
+ }
|
|
|
+
|
|
|
private void checkPhoneMessageOrThrowError(String phone, String phoneCode) {
|
|
|
if (!aliService.checkPhoneMessage(phone, phoneCode)) {
|
|
|
throw CustomErrorException.phoneVerificationNotMatch();
|