Commit 14990121 by 吴迪

【新增】修改bug

parent 41c2b99d
...@@ -5,6 +5,7 @@ import io.office.common.utils.R; ...@@ -5,6 +5,7 @@ import io.office.common.utils.R;
import io.office.modules.app.annotation.Login; import io.office.modules.app.annotation.Login;
import io.office.modules.manage.entity.LogLoginEntity; import io.office.modules.manage.entity.LogLoginEntity;
import io.office.modules.manage.service.LogLoginService; import io.office.modules.manage.service.LogLoginService;
import io.office.modules.manage.utils.PasswordValidator;
import io.office.modules.manage.vo.request.DomesticCodeVo; import io.office.modules.manage.vo.request.DomesticCodeVo;
import io.office.modules.sys.service.SysCaptchaService; import io.office.modules.sys.service.SysCaptchaService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -43,12 +44,27 @@ public class LogLoginController { ...@@ -43,12 +44,27 @@ public class LogLoginController {
public R login(@RequestBody Map<String, Object> params, HttpServletRequest request, HttpServletResponse response){ public R login(@RequestBody Map<String, Object> params, HttpServletRequest request, HttpServletResponse response){
DomesticCodeVo domesticCodeVo = new DomesticCodeVo(params.get("uuid").toString(),params.get("captcha").toString()); DomesticCodeVo domesticCodeVo = new DomesticCodeVo(params.get("uuid").toString(),params.get("captcha").toString());
boolean captcha = sysCaptchaService.validate(domesticCodeVo.getUuid(), domesticCodeVo.getCaptcha()); boolean captcha = sysCaptchaService.validate(domesticCodeVo.getUuid(), domesticCodeVo.getCaptcha());
//if(!captcha){ if(!captcha){
// return R.error("验证码不正确"); return R.error("验证码不正确");
//} }
return R.ok().put("data",logLoginService.loginNew2024(params,request,response)); return R.ok().put("data",logLoginService.loginNew2024(params,request,response));
} }
@RequestMapping("/authApi/checkPassWord")
@Login
// @RequiresPermissions("manage:member:list")
public R checkPassWord(@RequestBody Map<String, Object> params, HttpServletRequest request, HttpServletResponse response){
String passWord = params.get("passWord").toString();
if(!PasswordValidator.isValidPassword(passWord)) {
return R.error("密码错误");
} else{
return R.ok();
}
}
/** /**
* 列表 * 列表
......
...@@ -16,10 +16,7 @@ import io.office.modules.manage.dao.MemberDao; ...@@ -16,10 +16,7 @@ import io.office.modules.manage.dao.MemberDao;
import io.office.modules.manage.entity.LogLoginEntity; import io.office.modules.manage.entity.LogLoginEntity;
import io.office.modules.manage.entity.MemberEntity; import io.office.modules.manage.entity.MemberEntity;
import io.office.modules.manage.service.LogLoginService; import io.office.modules.manage.service.LogLoginService;
import io.office.modules.manage.utils.DESNewUtils; import io.office.modules.manage.utils.*;
import io.office.modules.manage.utils.DESUtils;
import io.office.modules.manage.utils.MD5Util;
import io.office.modules.manage.utils.PhoneNumberUtils;
import io.office.modules.sys.service.SysUserTokenService; import io.office.modules.sys.service.SysUserTokenService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpClient;
...@@ -280,6 +277,8 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity ...@@ -280,6 +277,8 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
@Override @Override
public JSONObject loginNew2024(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) { public JSONObject loginNew2024(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
//是否需要修改密码默认 不需要
String isNeedUpdatePassword = "0";
String userName = String.valueOf(params.get("userName") == null ? "" : params.get("userName")); String userName = String.valueOf(params.get("userName") == null ? "" : params.get("userName"));
String passWord = String.valueOf(params.get("passWord") == null ? "" : params.get("passWord")); String passWord = String.valueOf(params.get("passWord") == null ? "" : params.get("passWord"));
//String verification = String.valueOf(params.get("verification") == null ? "" : params.get("verification"));//验证码 //String verification = String.valueOf(params.get("verification") == null ? "" : params.get("verification"));//验证码
...@@ -397,9 +396,14 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity ...@@ -397,9 +396,14 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
if (!passwordMD5.equalsIgnoreCase(password)) { if (!passwordMD5.equalsIgnoreCase(password)) {
throw new RRException("用户名或密码错误!"); throw new RRException("用户名或密码错误!");
} }
//添加登录日志 log_login
//校验密码收否满足要求
if(!PasswordValidator.isValidPassword(passWord)) {
isNeedUpdatePassword ="1";
} }
} }
}
//添加登录日志 log_login
logLoginDao.insert(new LogLoginEntity(1, userName, search, carno, phone, new Date(), IPUtils.getIpAddr(request), request.getRequestURL().toString())); logLoginDao.insert(new LogLoginEntity(1, userName, search, carno, phone, new Date(), IPUtils.getIpAddr(request), request.getRequestURL().toString()));
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("userType", userType); jsonObject.put("userType", userType);
...@@ -407,6 +411,7 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity ...@@ -407,6 +411,7 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
jsonObject.put("carno", carno); jsonObject.put("carno", carno);
jsonObject.put("username", userName); jsonObject.put("username", userName);
jsonObject.put("phone", phone); jsonObject.put("phone", phone);
jsonObject.put("isNeedUpdatePassword", isNeedUpdatePassword);
R token = sysUserTokenService.createToken("qianduan_", Long.parseLong(id.trim()));//将token信息存入 数据库 R token = sysUserTokenService.createToken("qianduan_", Long.parseLong(id.trim()));//将token信息存入 数据库
Object token1 = token.get("token"); Object token1 = token.get("token");
jsonObject.put("token", token1); jsonObject.put("token", token1);
......
package io.office.modules.manage.service.impl; package io.office.modules.manage.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.office.common.exception.RRException; import io.office.common.exception.RRException;
import io.office.common.utils.IPUtils; import io.office.common.utils.IPUtils;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.*; import io.office.modules.manage.dao.*;
import io.office.modules.manage.entity.*; import io.office.modules.manage.entity.*;
import io.office.modules.manage.service.MemberService;
import io.office.modules.manage.utils.DateUtils; import io.office.modules.manage.utils.DateUtils;
import io.office.modules.manage.utils.MD5Util; import io.office.modules.manage.utils.MD5Util;
import io.office.modules.manage.utils.PasswordValidator;
import io.office.modules.manage.utils.PhoneNumberUtils; import io.office.modules.manage.utils.PhoneNumberUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.NameValuePair;
...@@ -17,18 +23,13 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,18 +23,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.service.MemberService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Service("memberService") @Service("memberService")
...@@ -162,6 +163,12 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl ...@@ -162,6 +163,12 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl
if (!newPass.equals(affirmPass)) { if (!newPass.equals(affirmPass)) {
throw new RRException("两次密码信息不一致,请重新输入"); throw new RRException("两次密码信息不一致,请重新输入");
} }
if(PasswordValidator.isValidPassword(newPass)) {
throw new RRException("密码不符合要求,密码应该包含数字、大小写字母和特殊字符(@$!%*#?&)中的任意两种,并且长度在8-20个字符之间");
}
MemberEntity memberEntity = memberDao.selectById(id); MemberEntity memberEntity = memberDao.selectById(id);
if(memberEntity!=null) { if(memberEntity!=null) {
String passData = memberEntity.getPass(); String passData = memberEntity.getPass();
......
package io.office.modules.manage.utils;
/**
* @author wudi
* @date 2024/1/27
* @comment
*/
public class PasswordValidator {
public static final String PASSWORD_PATTERN = "^(?=.*[@$!%*#?&]|\\d)(?=.*[A-Za-z])[A-Za-z\\d@$!%*#?&]{8,20}$";
public static final String PASSWORD_PATTERN_2 = "^(?=.*[A-Za-z]|\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,20}$";
public static final String PASSWORD_PATTERN_3 = "^(?=.*[A-Za-z]|[@$!%*#?&])(?=.*\\d)[A-Za-z\\d@$!%*#?&]{8,20}$";
public static final String pattern="^(?![\\d]+$)(?![a-z]+$)(?![A-Z]+$)(?![@$!%*#?&]+$)[\\da-zA-z@$!%*#?&]{8,20}$";
//public static boolean isValidPassword(String password) {
// if(password.matches(PASSWORD_PATTERN)||password.matches(PASSWORD_PATTERN_2)||password.matches(PASSWORD_PATTERN_3)) {
// return true;
// } else{
// return false;
// }
//}
public static boolean isValidPassword(String password) {
return password.matches(pattern);
}
public static void main(String[] args) {
String pattern="^(?![\\d]+$)(?![a-z]+$)(?![A-Z]+$)(?![@$!%*#?&]+$)[\\da-zA-z@$!%*#?&]{8,20}$";
String testPassword = "Password123";
String testPassword2 = "Password123#4355";
String testPassword3 = "34354545123#aAddd";
String testPassword4 = "Sdeeettttttt#";
String testPassword5 = "11111111a";
String testPassword6 = "asdcfghdddSSS";
System.out.println(testPassword.matches(pattern)); // 输出: true
System.out.println(testPassword2.matches(pattern));
System.out.println(testPassword3.matches(pattern));
System.out.println(testPassword4.matches(pattern));
System.out.println(testPassword5.matches(pattern));
System.out.println(testPassword6.matches(pattern));
System.out.println(MD5Util.md5Encrypt32Lower("11111111"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment