update 修改个人中心重置密码redis key 问题
This commit is contained in:
parent
ffff88bacf
commit
ca86a560dc
|
@ -139,7 +139,7 @@ public class TokenController {
|
|||
public R<?> resetPwd(@Valid @RequestBody ResetPwdBody resetPwdBody)
|
||||
{
|
||||
// 重置密码
|
||||
sysLoginService.resetPwd(resetPwdBody);
|
||||
sysLoginService.resetPwd(resetPwdBody,true);
|
||||
return R.success("账号"+ resetPwdBody.getEmail()+"密码重置成功");
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class TokenController {
|
|||
resetPwdBody.setEmail(email);
|
||||
|
||||
// 修改密码
|
||||
sysLoginService.resetPwd(resetPwdBody);
|
||||
sysLoginService.resetPwd(resetPwdBody,false);
|
||||
return R.success("账号"+ resetPwdBody.getEmail()+"密码修改成功");
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ public class ResetPwdBody {
|
|||
|
||||
private String resetPwdCode;
|
||||
|
||||
private String updatePwdCode;
|
||||
|
||||
/** 新密码 */
|
||||
private String password;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.m2pool.system.api.RemoteUserService;
|
|||
import com.m2pool.system.api.entity.SysLogininfor;
|
||||
import com.m2pool.system.api.entity.SysUser;
|
||||
import com.m2pool.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -41,6 +42,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* @Date 2024/6/12 16:19
|
||||
* @Author dy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SysLoginService {
|
||||
|
||||
|
@ -404,11 +406,11 @@ public class SysLoginService {
|
|||
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*
|
||||
*/
|
||||
public void resetPwd(ResetPwdBody resetPwdBody)
|
||||
public void resetPwd(ResetPwdBody resetPwdBody,boolean isUpdate)
|
||||
{
|
||||
|
||||
log.info("验证码{},重置密码{},重置者邮箱{}",resetPwdBody.getResetPwdCode(),resetPwdBody.getPassword(),resetPwdBody.getEmail());
|
||||
String password = resetPwdBody.getPassword();
|
||||
try {
|
||||
password = RsaUtils.decryptByPrivateKey(resetPwdBody.getPassword());
|
||||
|
@ -419,6 +421,7 @@ public class SysLoginService {
|
|||
|
||||
String email = resetPwdBody.getEmail();
|
||||
String resetPwdCode = resetPwdBody.getResetPwdCode();
|
||||
String updatePwdCode = resetPwdBody.getUpdatePwdCode();
|
||||
// 邮箱或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(email, password))
|
||||
{
|
||||
|
@ -466,8 +469,9 @@ public class SysLoginService {
|
|||
//
|
||||
//System.out.println(checkCodeResult);
|
||||
|
||||
if(redisService.hasKey(RedisTransKey.getResetPwdKey(email))){
|
||||
|
||||
log.info("重置密码{},修改验证码{},重置验证码{}",isUpdate,redisService.hasKey(RedisTransKey.getResetPwdKey(email)),redisService.hasKey(RedisTransKey.getUpdatePwdKey(email)));
|
||||
// 如果是true代表就是忘记密码 false 就是个人中心重置密码
|
||||
if(isUpdate && redisService.hasKey(RedisTransKey.getResetPwdKey(email))){
|
||||
Object o = redisService.getCacheObject(RedisTransKey.getResetPwdKey(email));//user:emailCode:username
|
||||
|
||||
EmailCodeEntity emailCodeEntity = JSON.parseObject(JSON.toJSONString(o), EmailCodeEntity.class);
|
||||
|
@ -493,6 +497,32 @@ public class SysLoginService {
|
|||
}else {
|
||||
throw new ServiceException("请勿修改已输入的邮箱");
|
||||
}
|
||||
}else if(!isUpdate && redisService.hasKey(RedisTransKey.getUpdatePwdKey(email))){
|
||||
Object o = redisService.getCacheObject(RedisTransKey.getUpdatePwdKey(email));//user:emailCode:username
|
||||
|
||||
EmailCodeEntity emailCodeEntity = JSON.parseObject(JSON.toJSONString(o), EmailCodeEntity.class);
|
||||
if (email.equals(emailCodeEntity.getEmail())) {
|
||||
//邮箱必须和刚刚传的一致
|
||||
//验证验证码
|
||||
if(updatePwdCode.equals(emailCodeEntity.getEmailCode())){
|
||||
// 重置用户密码
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setEmail(email);
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||
|
||||
R<?> resetPwdResult = remoteUserService.resetPwdByEmail(sysUser);
|
||||
|
||||
if (R.FAIL == resetPwdResult.getCode())
|
||||
{
|
||||
throw new ServiceException(resetPwdResult.getMsg());
|
||||
}
|
||||
//recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
}else {
|
||||
throw new ServiceException("邮箱验证码错误");
|
||||
}
|
||||
}else {
|
||||
throw new ServiceException("请勿修改已输入的邮箱");
|
||||
}
|
||||
}else {
|
||||
////判断是邮箱不存在还是操作超时
|
||||
////通过邮箱获取用户
|
||||
|
@ -503,7 +533,6 @@ public class SysLoginService {
|
|||
//}
|
||||
throw new ServiceException("验证码校验失败:操作超时,请重新操作");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ public class PoolController extends BaseController {
|
|||
}
|
||||
|
||||
@PostMapping("/getMinerPowerFor30min")
|
||||
@ApiOperation(value = "根据矿工账号从hashrate库获取30m的平均算力")
|
||||
@ApiOperation(value = "根据矿工账号从hashrate库获取算力")
|
||||
public AjaxResult getMinerPowerFor30min(@RequestBody MinerMhsVo minerMhsVo){
|
||||
return poolService.getMinerPowerFor30min(minerMhsVo);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.m2pool.pool.task;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.m2pool.common.core.utils.DateUtils;
|
||||
import com.m2pool.common.core.utils.StringUtils;
|
||||
import com.m2pool.common.redis.service.RedisService;
|
||||
|
@ -12,6 +14,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
@ -503,20 +507,51 @@ public class NodeTask {
|
|||
@Scheduled(cron = "0 2 0/1 * * ?")
|
||||
//@Scheduled(cron = "0 0/2 * * * ?")
|
||||
public void insertNetBlock(){
|
||||
Date now = new Date();
|
||||
now.setMinutes( 0);
|
||||
now.setSeconds(0);
|
||||
|
||||
String date = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now);
|
||||
insertBlockWithRetry("nexa", "nexa_net_block", 5);
|
||||
insertBlockWithRetry("mona", "mona_net_block", 5);
|
||||
insertBlockWithRetry("rxd", "rxd_net_block", 5);
|
||||
insertBlockWithRetry("grs", "grs_net_block", 5);
|
||||
|
||||
insertBlockWithAlph(3);
|
||||
//下列三种币 高度是共用的
|
||||
insertBlockWithDgbSeries(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* alph 币种高度入库
|
||||
*/
|
||||
private void insertBlockWithAlph(int maxRetries){
|
||||
int retryCount = 0;
|
||||
while (retryCount < maxRetries) {
|
||||
try {
|
||||
String url = "http://18.141.161.129:12973/blockflow/chain-info?fromGroup=0&toGroup=0";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Content-Type","application/json");
|
||||
headers.add("User-Agent", "Mozilla/5.0");
|
||||
headers.add("apikey","0x09e220e226f2feb7a971a2b6f958e7d4b1c187c8");
|
||||
HttpEntity<String> httpEntity = new HttpEntity<String>(null, headers);
|
||||
String s = HttpUtil.get(url);
|
||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||
int currentHeight = jsonObject.getIntValue("currentHeight");
|
||||
poolMapper.insertNetBlock("alph_net_block", (long) currentHeight);
|
||||
log.info("插入币种 alph,插入的最新高度为{}",currentHeight);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
retryCount++;
|
||||
if (retryCount >= maxRetries) {
|
||||
log.error("插入区块 alph 数据失败,重试 {} 次后仍失败", maxRetries, e);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* nexa,mona,rxd,grs 币种高度入库
|
||||
* @param blockName
|
||||
|
|
|
@ -138,6 +138,7 @@ public class NodeRpc{
|
|||
throw new RuntimeException("当前请求接口的用户过多,请稍后再试");
|
||||
}
|
||||
if(result.contains("error:")){
|
||||
System.out.println("验证地址包含错误:"+result + "钱包地址"+address);
|
||||
return false;
|
||||
}else {
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
|
|
Loading…
Reference in New Issue