| | |
| | | package com.ruoyi.auth.service; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | |
| | | import com.ruoyi.system.api.RemoteUserService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 登录校验方法 |
| | |
| | | } |
| | | recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功"); |
| | | } |
| | | |
| | | public void changePassword(String username, String password, String verificationCode) { |
| | | String verificationCodeCache = Convert.toStr( |
| | | redisService.getCacheObject( |
| | | CacheConstants.CHANGE_PASSWORD_CAPTCHA_CODE_KEY + username)); |
| | | if (StringUtils.isEmpty(verificationCodeCache)) { |
| | | throw new ServiceException("验证码已过期,请重新获取!"); |
| | | } |
| | | if (!verificationCodeCache.equals(verificationCode)) { |
| | | throw new ServiceException("验证码错误,请重新输入!"); |
| | | } |
| | | R<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.INNER); |
| | | if (R.FAIL == userInfo.getCode()) { |
| | | throw new ServiceException(userInfo.getMsg()); |
| | | } |
| | | if (!passwordService.matches(userInfo.getData().getSysUser(), password)) { |
| | | throw new ServiceException("旧密码错误,请重新输入!"); |
| | | } |
| | | remoteUserService.changePassword(username, SecurityUtils.encryptPassword(password), |
| | | SecurityConstants.INNER); |
| | | } |
| | | } |