创建店铺密码强度校验

修改密码 可通过验证码
发送验证码类型限制
This commit is contained in:
2026-04-27 10:08:16 +08:00
parent c3ae15c7cc
commit 91fc6643a8
10 changed files with 93 additions and 38 deletions

View File

@@ -1,6 +1,8 @@
package com.czg.utils;
import cn.hutool.core.text.PasswdStrength;
import cn.hutool.core.util.StrUtil;
import com.czg.exception.CzgException;
import java.time.LocalDate;
@@ -21,6 +23,7 @@ public class CzgStrUtils {
/**
* 获取当天是周几
*
* @return 周几
*/
public static String getStrWeek() {
@@ -31,4 +34,17 @@ public class CzgStrUtils {
return "" + chineseWeeks[dayOfWeek];
}
public static void checkPwd(String pwd) {
if (StrUtil.isBlank(pwd)) {
throw new CzgException("密码不能为空");
}
if (pwd.length() < 6) {
throw new CzgException("密码长度不能小于6");
}
PasswdStrength.PASSWD_LEVEL level = PasswdStrength.getLevel(pwd);
if (level == PasswdStrength.PASSWD_LEVEL.EASY) {
throw new CzgException("密码强度弱,需包含字母、数字、特殊符号中至少两种");
}
}
}