This commit is contained in:
lijiaqi 2023-07-12 16:23:33 +08:00
parent 1ffdfcc71c
commit 239002ea79
3 changed files with 5 additions and 5 deletions

View File

@ -12,7 +12,7 @@ import java.util.regex.Pattern;
public class PasswordUtil { public class PasswordUtil {
public static Boolean valid(String password) { public static Boolean valid(String password) {
String regexp = "^.*(?=.*\\d)(?=.*[A-Za-z])(?=.*[!@#$%^&*?_]).{6,}$"; String regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*])[a-zA-Z\\d!@#$%^&*]{8,}$\n";
return Pattern.matches(regexp, password); return Pattern.matches(regexp, password);
} }

View File

@ -146,7 +146,7 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
*/ */
@Override @Override
public AjaxResult editPassword(String oldPassword, String newPassword) { public AjaxResult editPassword(String oldPassword, String newPassword) {
if (!PasswordUtil.valid(newPassword)) return AjaxResult.fail("密码需由长度不小于6位的英文、数字及特殊符号组成"); if (!PasswordUtil.valid(newPassword)) return AjaxResult.fail("密码必须同时包含大写字母、小写字母、数字和特殊字符并且长度至少为8位");
String loginId = StpUtil.getLoginIdAsString(); String loginId = StpUtil.getLoginIdAsString();
User user = getById(loginId); User user = getById(loginId);
if (!user.getPassword().equals(PasswordUtil.password(user.getSalt(), oldPassword))) return AjaxResult.fail( if (!user.getPassword().equals(PasswordUtil.password(user.getSalt(), oldPassword))) return AjaxResult.fail(
@ -168,7 +168,7 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
*/ */
@Override @Override
public AjaxResult newPassword(String newPassword) { public AjaxResult newPassword(String newPassword) {
if (!PasswordUtil.valid(newPassword)) return AjaxResult.fail("密码需由长度不小于6位的英文、数字及特殊符号组成"); if (!PasswordUtil.valid(newPassword)) return AjaxResult.fail("密码必须同时包含大写字母、小写字母、数字和特殊字符并且长度至少为8位");
String loginId = StpUtil.getLoginIdAsString(); String loginId = StpUtil.getLoginIdAsString();
String salt = RandomUtil.randomString(6); String salt = RandomUtil.randomString(6);
String password = PasswordUtil.password(salt, newPassword); String password = PasswordUtil.password(salt, newPassword);

View File

@ -16,9 +16,9 @@ spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://10.0.0.54:3306/lc_oa?useSSL=false&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF8&autoReconnect=true&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true url: jdbc:mysql://localhost:3306/lc_oa?useSSL=false&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF8&autoReconnect=true&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root username: root
password: zyy200916 password: Wang09211108
druid: druid:
# 下面为连接池的补充设置,应用到上面所有数据源中 # 下面为连接池的补充设置,应用到上面所有数据源中
# 初始化大小,最小,最大 # 初始化大小,最小,最大