mirror of https://gitee.com/stylefeng/roses
parent
7e2e6894fd
commit
47d26c0a6b
|
@ -198,4 +198,12 @@ public interface SysUserServiceApi {
|
|||
*/
|
||||
UserInfoDetailDTO getUserDetailByEmail(String email);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/12 14:55
|
||||
*/
|
||||
void resetPassword(Long userId, String newPassword);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
|||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.PermissionCodeConstants;
|
||||
import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRoleRequest;
|
||||
|
@ -152,7 +153,11 @@ public class SysUserController {
|
|||
requirePermissionCode = PermissionCodeConstants.RESET_PASSWORD)
|
||||
@BizLog(logTypeCode = PermissionCodeConstants.RESET_PASSWORD)
|
||||
public ResponseData<?> resetPassword(@RequestBody @Validated(SysUserRequest.resetPassword.class) SysUserRequest sysUserRequest) {
|
||||
sysUserService.resetPassword(sysUserRequest);
|
||||
|
||||
// 获取系统配置的默认密码
|
||||
String password = SysConfigExpander.getDefaultPassWord();
|
||||
|
||||
sysUserService.resetPassword(sysUserRequest.getUserId(), password);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.user.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.log.api.pojo.entity.SysLogBusinessContent;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
||||
|
@ -91,14 +90,6 @@ public interface SysUserService extends IService<SysUser>, SysUserServiceApi {
|
|||
*/
|
||||
void updateStatus(SysUserRequest sysUserRequest);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/12 14:55
|
||||
*/
|
||||
void resetPassword(SysUserRequest sysUserRequest);
|
||||
|
||||
/**
|
||||
* 获取当前用户的个人信息详情
|
||||
*
|
||||
|
|
|
@ -30,7 +30,6 @@ import cn.stylefeng.roses.kernel.sys.api.SecurityConfigService;
|
|||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
|
||||
import cn.stylefeng.roses.kernel.sys.api.enums.user.UserStatusEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.*;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
|
||||
|
@ -293,15 +292,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void resetPassword(SysUserRequest sysUserRequest) {
|
||||
public void resetPassword(Long userId, String newPassword) {
|
||||
|
||||
SysUser sysUser = this.querySysUser(sysUserRequest);
|
||||
|
||||
// 获取系统配置的默认密码
|
||||
String password = SysConfigExpander.getDefaultPassWord();
|
||||
SysUser sysUser = this.getById(userId);
|
||||
|
||||
// 密码加密后,存储到数据库中
|
||||
SaltedEncryptResult saltedEncryptResult = passwordStoredEncryptApi.encryptWithSalt(password);
|
||||
SaltedEncryptResult saltedEncryptResult = passwordStoredEncryptApi.encryptWithSalt(newPassword);
|
||||
sysUser.setPassword(saltedEncryptResult.getEncryptPassword());
|
||||
sysUser.setPasswordSalt(saltedEncryptResult.getPasswordSalt());
|
||||
|
||||
|
|
Loading…
Reference in New Issue