修改密码 测试完成。
This commit is contained in:
parent
d4538e6e88
commit
de09ecd2aa
@ -2,6 +2,12 @@ package com.ruoyi.web.controller.app;
|
||||
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.user.CaptchaException;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||
import com.ruoyi.system.domain.BaiduCardBack;
|
||||
import com.ruoyi.system.domain.BaiduIdCard;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
@ -17,13 +23,11 @@ import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.service.SysLoginService;
|
||||
import com.ruoyi.framework.web.service.SysRegisterService;
|
||||
import com.ruoyi.system.domain.dto.*;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.IUserInfoService;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.domain.UserInfo;
|
||||
import com.ruoyi.system.domain.dto.OutRealNameAuthenticationDto;
|
||||
import com.ruoyi.system.domain.dto.RealNameAuthenticationDto;
|
||||
import com.ruoyi.system.domain.dto.UpdatePwdDto;
|
||||
import com.ruoyi.system.domain.dto.UploadAvatarDto;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.web.controller.app.baidu.GsonUtils;
|
||||
import com.ruoyi.web.controller.app.baidu.OcrIdCardBAI;
|
||||
@ -59,6 +63,12 @@ public class AppSystemController {
|
||||
@Autowired
|
||||
private SysRegisterService registerService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
|
||||
/**
|
||||
* 账号密码登录
|
||||
@ -89,6 +99,41 @@ public class AppSystemController {
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
/*
|
||||
* 跟新密码时的验证码对比
|
||||
* */
|
||||
@PostMapping("/verifyUpdatePasswordSms")
|
||||
public AjaxResult verifyUpdatePasswordSms(@RequestBody PhoneSMSDto phoneSMSDto) {
|
||||
|
||||
String username = phoneSMSDto.getUsername();
|
||||
// String phone = phoneSMSDto.getUsername();
|
||||
String code = phoneSMSDto.getCode();
|
||||
|
||||
|
||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||
if (captchaEnabled) {
|
||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + username;
|
||||
String captcha = redisCache.getCacheObject(verifyKey);
|
||||
// System.out.println(captcha);
|
||||
// 删除缓存中的验证码
|
||||
redisCache.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
|
||||
return error("验证码过期");
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha))
|
||||
{
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
|
||||
// throw new CaptchaException();
|
||||
return error("验证码错误");
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
return error("服务未开放");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
@ -103,12 +148,32 @@ public class AppSystemController {
|
||||
}
|
||||
|
||||
|
||||
//更新密码
|
||||
@PutMapping("/updatePwd")
|
||||
public AjaxResult updatePwd(@RequestBody UpdatePwdDto updatepwdDto)
|
||||
{
|
||||
// String oldPassword = updatepwdDto.getOldPassword();
|
||||
String newPassword = updatepwdDto.getNewPassword();
|
||||
String phone = updatepwdDto.getPhone();
|
||||
String code = updatepwdDto.getCode();
|
||||
|
||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + phone;
|
||||
String captcha = redisCache.getCacheObject(verifyKey);
|
||||
// System.out.println(captcha);
|
||||
// 删除缓存中的验证码
|
||||
redisCache.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(phone, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
|
||||
return error("验证码过期");
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha))
|
||||
{
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(phone, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
|
||||
// throw new CaptchaException();
|
||||
return error("验证码错误");
|
||||
}
|
||||
|
||||
|
||||
SysUser sysUser = sysUserService.selectUserByUserName(phone);
|
||||
if (sysUser == null)
|
||||
{
|
||||
|
||||
@ -105,7 +105,7 @@ public class CaptchaController {
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@GetMapping("/appRegisterCaptchaCode/{phone}")
|
||||
@GetMapping("/appCaptchaCode/{phone}")
|
||||
public AjaxResult getAppRegisterCode(@PathVariable String phone) throws IOException {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
|
||||
@ -120,6 +120,15 @@ public class CaptchaController {
|
||||
sendCacheCode(phone);
|
||||
return AjaxResult.success(phone);
|
||||
}
|
||||
// @GetMapping("/appUpdatePasswordCaptchaCode/{phone}")
|
||||
// public AjaxResult getUpdatePasswordCode(@PathVariable String phone) throws IOException {
|
||||
// AjaxResult ajax = AjaxResult.success();
|
||||
//
|
||||
// // 保存验证码信息
|
||||
//// String uuid = IdUtils.simpleUUID();
|
||||
// sendCacheCode(phone);
|
||||
// return AjaxResult.success(phone);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -119,7 +119,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
||||
// 过滤请求
|
||||
.authorizeRequests()
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
.antMatchers("/login", "/register", "/captchaImage","/appLoginCaptchaCode/**","/appRegisterCaptchaCode/**","/app/system/**").permitAll()
|
||||
.antMatchers("/login", "/register", "/captchaImage","/appLoginCaptchaCode/**","/appCaptchaCode/**","/appUpdatePasswordCaptchaCode/**","/app/system/**").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package com.ruoyi.system.domain.dto;
|
||||
|
||||
public class PhoneSMSDto {
|
||||
private String username;
|
||||
private String code;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ public class UpdatePwdDto {
|
||||
// private String oldPassword;
|
||||
private String newPassword;
|
||||
private String phone;
|
||||
private String code;
|
||||
|
||||
// public String getOldPassword() {
|
||||
// return oldPassword;
|
||||
@ -28,4 +29,10 @@ public class UpdatePwdDto {
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user