update m2pool 新增注销账号功能
This commit is contained in:
@@ -3,6 +3,7 @@ package com.m2pool.system.api;
|
|||||||
import com.m2pool.common.core.Result.R;
|
import com.m2pool.common.core.Result.R;
|
||||||
import com.m2pool.common.core.constant.SecurityConstants;
|
import com.m2pool.common.core.constant.SecurityConstants;
|
||||||
import com.m2pool.common.core.constant.ServiceNameConstants;
|
import com.m2pool.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.m2pool.system.api.entity.CloseAccountVo;
|
||||||
import com.m2pool.system.api.entity.SysUser;
|
import com.m2pool.system.api.entity.SysUser;
|
||||||
import com.m2pool.system.api.entity.SysUserLeveDate;
|
import com.m2pool.system.api.entity.SysUserLeveDate;
|
||||||
import com.m2pool.system.api.factory.RemoteUserFallbackFactory;
|
import com.m2pool.system.api.factory.RemoteUserFallbackFactory;
|
||||||
@@ -82,7 +83,7 @@ public interface RemoteUserService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/profile/checkGoogleCode")
|
@PostMapping("/user/profile/checkGoogleCode")
|
||||||
public R<Boolean> checkGoogleCode(@RequestBody Long code, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
public R<Boolean> checkGoogleCode(@RequestBody CloseAccountVo closeAccountVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取客服列表
|
* 获取客服列表
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.m2pool.system.api.factory;
|
|||||||
|
|
||||||
import com.m2pool.common.core.Result.R;
|
import com.m2pool.common.core.Result.R;
|
||||||
import com.m2pool.system.api.RemoteUserService;
|
import com.m2pool.system.api.RemoteUserService;
|
||||||
|
import com.m2pool.system.api.entity.CloseAccountVo;
|
||||||
import com.m2pool.system.api.entity.SysUser;
|
import com.m2pool.system.api.entity.SysUser;
|
||||||
import com.m2pool.system.api.entity.SysUserLeveDate;
|
import com.m2pool.system.api.entity.SysUserLeveDate;
|
||||||
import com.m2pool.system.api.model.LoginUser;
|
import com.m2pool.system.api.model.LoginUser;
|
||||||
@@ -60,7 +61,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> checkGoogleCode(Long code, String source) {
|
public R<Boolean> checkGoogleCode(CloseAccountVo closeAccountVo, String source) {
|
||||||
return R.fail("谷歌验证器校验失败:" + cause.getMessage());
|
return R.fail("谷歌验证器校验失败:" + cause.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,12 +99,11 @@ public class TokenController {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭注销账户
|
* 注销账户
|
||||||
* @param closeAccountVo
|
* @param closeAccountVo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/closeAccount")
|
@PostMapping("/closeAccount")
|
||||||
@RequiresLogin
|
|
||||||
@ApiOperation(value = "用户注销")
|
@ApiOperation(value = "用户注销")
|
||||||
public R<?> closeAccount(@RequestBody @Valid CloseAccountVo closeAccountVo){
|
public R<?> closeAccount(@RequestBody @Valid CloseAccountVo closeAccountVo){
|
||||||
return sysLoginService.closeAccount(closeAccountVo);
|
return sysLoginService.closeAccount(closeAccountVo);
|
||||||
|
|||||||
@@ -578,6 +578,7 @@ public class SysLoginService {
|
|||||||
throw new ServiceException("邮箱为必填项");
|
throw new ServiceException("邮箱为必填项");
|
||||||
}
|
}
|
||||||
String closeAccountKey = RedisTransKey.getCloseAccountKey(email);
|
String closeAccountKey = RedisTransKey.getCloseAccountKey(email);
|
||||||
|
System.out.println("redis 的 key"+closeAccountKey);
|
||||||
//校验谷歌验证码和邮箱验证码
|
//校验谷歌验证码和邮箱验证码
|
||||||
if(redisService.hasKey(closeAccountKey)){
|
if(redisService.hasKey(closeAccountKey)){
|
||||||
Object o = redisService.getCacheObject(closeAccountKey);//user:emailCode:email
|
Object o = redisService.getCacheObject(closeAccountKey);//user:emailCode:email
|
||||||
@@ -591,8 +592,8 @@ public class SysLoginService {
|
|||||||
}else {
|
}else {
|
||||||
throw new ServiceException("验证码未获取或已过期,请重新获取验证码");
|
throw new ServiceException("验证码未获取或已过期,请重新获取验证码");
|
||||||
}
|
}
|
||||||
R<Boolean> booleanR1 = remoteUserService.checkGoogleCode(closeAccountVo.getGCode(), SecurityConstants.INNER);
|
R<Boolean> booleanR1 = remoteUserService.checkGoogleCode(closeAccountVo, SecurityConstants.INNER);
|
||||||
if(!booleanR1.getData()){
|
if((booleanR1 != null && booleanR1.getData() == null) || !booleanR1.getData()){
|
||||||
throw new ServiceException("谷歌验证码错误");
|
throw new ServiceException("谷歌验证码错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -572,6 +572,7 @@ public class MaliServiceImpl implements MailService {
|
|||||||
|
|
||||||
//判断用户是不是恶意刷邮箱,在规定时间内进行的
|
//判断用户是不是恶意刷邮箱,在规定时间内进行的
|
||||||
String closeAccountKey = RedisTransKey.getCloseAccountKey(email);
|
String closeAccountKey = RedisTransKey.getCloseAccountKey(email);
|
||||||
|
System.out.println("redis 的 key"+closeAccountKey);
|
||||||
if (redisService.hasKey(closeAccountKey)) {
|
if (redisService.hasKey(closeAccountKey)) {
|
||||||
|
|
||||||
Object o = redisService.getCacheObject(closeAccountKey);//user:updatePwdCode:email
|
Object o = redisService.getCacheObject(closeAccountKey);//user:updatePwdCode:email
|
||||||
@@ -602,7 +603,7 @@ public class MaliServiceImpl implements MailService {
|
|||||||
);
|
);
|
||||||
sendCloseAccountMailMessage(email, emailCodeEntity.getEmailCode());
|
sendCloseAccountMailMessage(email, emailCodeEntity.getEmailCode());
|
||||||
}
|
}
|
||||||
return R.success("请求成功,修改密码验证码已经发送至用户邮箱");
|
return R.success("请求成功,注销账户邮箱验证码发送成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.m2pool.common.security.annotation.InnerAuth;
|
|||||||
import com.m2pool.common.security.annotation.RequiresLogin;
|
import com.m2pool.common.security.annotation.RequiresLogin;
|
||||||
import com.m2pool.common.security.service.TokenService;
|
import com.m2pool.common.security.service.TokenService;
|
||||||
import com.m2pool.common.security.utils.SecurityUtils;
|
import com.m2pool.common.security.utils.SecurityUtils;
|
||||||
|
import com.m2pool.system.api.entity.CloseAccountVo;
|
||||||
import com.m2pool.system.api.entity.SysRole;
|
import com.m2pool.system.api.entity.SysRole;
|
||||||
import com.m2pool.system.api.entity.SysUser;
|
import com.m2pool.system.api.entity.SysUser;
|
||||||
import com.m2pool.system.api.entity.SysUserLeveDate;
|
import com.m2pool.system.api.entity.SysUserLeveDate;
|
||||||
@@ -200,8 +201,8 @@ public class SysProfileController extends BaseController
|
|||||||
@InnerAuth
|
@InnerAuth
|
||||||
@ApiOperation(value = "谷歌安全验证码验证")
|
@ApiOperation(value = "谷歌安全验证码验证")
|
||||||
@PostMapping("/checkGoogleCode")
|
@PostMapping("/checkGoogleCode")
|
||||||
public R<Boolean> checkGoogleCode(@RequestBody Long code){
|
public R<Boolean> checkGoogleCode(@RequestBody CloseAccountVo closeAccountVo){
|
||||||
return R.success(userService.checkGoogleCode(code));
|
return R.success(userService.checkGoogleCode(closeAccountVo.getGCode(),closeAccountVo.getUserEmail()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,6 @@ public class SysUserController extends BaseController {
|
|||||||
return R.success(list);
|
return R.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresLogin
|
|
||||||
@PostMapping("/closeAccount")
|
@PostMapping("/closeAccount")
|
||||||
@ApiOperation(value = "用户注销")
|
@ApiOperation(value = "用户注销")
|
||||||
public AjaxResult closeAccount(@RequestBody SysUser sysUser){
|
public AjaxResult closeAccount(@RequestBody SysUser sysUser){
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public interface SysUserService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
* @param code
|
* @param code
|
||||||
*/
|
*/
|
||||||
public boolean checkGoogleCode(Long code);
|
public boolean checkGoogleCode(long code,String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有聊天客服
|
* 查询所有聊天客服
|
||||||
|
|||||||
@@ -381,9 +381,9 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkGoogleCode(Long code) {
|
public boolean checkGoogleCode(long code,String username) {
|
||||||
String username = SecurityUtils.getUsername();
|
|
||||||
|
|
||||||
|
System.out.println("用户名:"+username);
|
||||||
//谷歌验证码校验
|
//谷歌验证码校验
|
||||||
GoogleInfo info = userMapper.getGoogleInfoByEmail(username);
|
GoogleInfo info = userMapper.getGoogleInfoByEmail(username);
|
||||||
if(StringUtils.isNull(info)){
|
if(StringUtils.isNull(info)){
|
||||||
@@ -403,7 +403,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
if(GoogleAuthenticator.checkCode(info.getSecret(), code, System.currentTimeMillis())){
|
if(GoogleAuthenticator.checkCode(info.getSecret(), code, System.currentTimeMillis())){
|
||||||
return true;
|
return true;
|
||||||
}else {
|
}else {
|
||||||
throw new ServiceException("验证码错误");
|
throw new ServiceException("谷歌验证码错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<update id="closeUser">
|
<update id="closeUser">
|
||||||
update sys_user
|
update sys_user
|
||||||
<set>
|
<set>
|
||||||
<if test="delFlag != null">delFlag = #{delFlag},</if>
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
|
|||||||
Reference in New Issue
Block a user