| | |
| | | <!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/lianhelihua_admin/icon.png"><title>èåå©åäºä»¶ä¸æ¥ç³»ç»</title><link href="/lianhelihua_admin/static/css/app.b20beb91.css" rel="preload" as="style"><link href="/lianhelihua_admin/static/css/chunk-vendors.d9e68312.css" rel="preload" as="style"><link href="/lianhelihua_admin/static/js/app.17e4dc64.js" rel="preload" as="script"><link href="/lianhelihua_admin/static/js/chunk-vendors.40d691b2.js" rel="preload" as="script"><link href="/lianhelihua_admin/static/css/chunk-vendors.d9e68312.css" rel="stylesheet"><link href="/lianhelihua_admin/static/css/app.b20beb91.css" rel="stylesheet"></head><body><div id="app"></div><script src="/lianhelihua_admin/static/js/chunk-vendors.40d691b2.js"></script><script src="/lianhelihua_admin/static/js/app.17e4dc64.js"></script></body></html> |
| | | <!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/lianhelihua_admin/icon.png"><title>èåå©åäºä»¶ä¸æ¥ç³»ç»</title><link href="/lianhelihua_admin/static/css/app.c56f0a7d.css" rel="preload" as="style"><link href="/lianhelihua_admin/static/css/chunk-vendors.d9e68312.css" rel="preload" as="style"><link href="/lianhelihua_admin/static/js/app.f5e3eac0.js" rel="preload" as="script"><link href="/lianhelihua_admin/static/js/chunk-vendors.174acd1e.js" rel="preload" as="script"><link href="/lianhelihua_admin/static/css/chunk-vendors.d9e68312.css" rel="stylesheet"><link href="/lianhelihua_admin/static/css/app.c56f0a7d.css" rel="stylesheet"></head><body><div id="app"></div><script src="/lianhelihua_admin/static/js/chunk-vendors.174acd1e.js"></script><script src="/lianhelihua_admin/static/js/app.f5e3eac0.js"></script></body></html> |
| | |
| | | { required: true, message: '请è¾å
¥åå§å¯ç ' } |
| | | ], |
| | | newPwd: [ |
| | | { required: true, message: '请è¾å
¥æ°å¯ç ' } |
| | | { required: true, message: '请è¾å
¥å¯ç ', trigger: 'blur' }, |
| | | { validator: this.validatePassword, trigger: 'blur' }, |
| | | ], |
| | | confirmPwd: [ |
| | | { required: true, message: 'è¯·åæ¬¡è¾å
¥æ°å¯ç ' } |
| | |
| | | this.$refs.changePwdDataForm.resetFields() |
| | | }) |
| | | }, |
| | | validatePassword(rule, value, callback) { |
| | | if (!value) { |
| | | callback(new Error('请è¾å
¥å¯ç ')) |
| | | } else { |
| | | const lengthValid = /^.{6,20}$/.test(value) |
| | | const hasLetter = /[a-zA-Z]/.test(value) |
| | | const hasNumber = /[0-9]/.test(value) |
| | | const hasSpecial = /[!@#$%^&*(),.?":{}|<>]/.test(value) |
| | | |
| | | const typesCount = [hasLetter, hasNumber, hasSpecial].filter(Boolean).length |
| | | |
| | | if (!lengthValid) { |
| | | callback(new Error('å¯ç é¿åº¦é为6å°20个å符')) |
| | | } else if (typesCount < 2) { |
| | | callback(new Error('å¯ç éå
å«åæ¯ãæ°ååç¹æ®å符ä¸çè³å°ä¸¤ç§')) |
| | | } else { |
| | | callback() // éªè¯éè¿ |
| | | } |
| | | } |
| | | }, |
| | | /** |
| | | * ç¡®å®ä¿®æ¹å¯ç |
| | | */ |
| | |
| | | { required: true, message: '请è¾å
¥å§å' } |
| | | ], |
| | | password: [ |
| | | { required: true, message: '请è¾å
¥å¯ç ' } |
| | | { required: true, message: '请è¾å
¥å¯ç ', trigger: 'blur' }, |
| | | { validator: this.validatePassword, trigger: 'blur' } |
| | | ], |
| | | avatar: [ |
| | | { required: true, message: 'è¯·éæ©ç¨æ·å¤´å' } |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | validatePassword (rule, value, callback) { |
| | | if (!value) { |
| | | callback(new Error('请è¾å
¥å¯ç ')) |
| | | } else { |
| | | const lengthValid = /^.{6,20}$/.test(value) |
| | | const hasLetter = /[a-zA-Z]/.test(value) |
| | | const hasNumber = /[0-9]/.test(value) |
| | | const hasSpecial = /[!@#$%^&*(),.?":{}|<>]/.test(value) |
| | | |
| | | const typesCount = [hasLetter, hasNumber, hasSpecial].filter(Boolean).length |
| | | |
| | | if (!lengthValid) { |
| | | callback(new Error('å¯ç é¿åº¦é为6å°20个å符')) |
| | | } else if (typesCount < 2) { |
| | | callback(new Error('å¯ç éå
å«åæ¯ãæ°ååç¹æ®å符ä¸çè³å°ä¸¤ç§')) |
| | | } else { |
| | | callback() // éªè¯éè¿ |
| | | } |
| | | } |
| | | }, |
| | | /** |
| | | * æå¼çªå£ |
| | | * |
| | |
| | | }, |
| | | rules: { |
| | | password: [ |
| | | { required: true, message: '请è¾å
¥å¯ç ' } |
| | | { required: true, message: '请è¾å
¥å¯ç ', trigger: 'blur' }, |
| | | { validator: this.validatePassword, trigger: 'blur' } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | validatePassword (rule, value, callback) { |
| | | if (!value) { |
| | | callback(new Error('请è¾å
¥å¯ç ')) |
| | | } else { |
| | | const lengthValid = /^.{6,20}$/.test(value) |
| | | const hasLetter = /[a-zA-Z]/.test(value) |
| | | const hasNumber = /[0-9]/.test(value) |
| | | const hasSpecial = /[!@#$%^&*(),.?":{}|<>]/.test(value) |
| | | |
| | | const typesCount = [hasLetter, hasNumber, hasSpecial].filter(Boolean).length |
| | | |
| | | if (!lengthValid) { |
| | | callback(new Error('å¯ç é¿åº¦é为6å°20个å符')) |
| | | } else if (typesCount < 2) { |
| | | callback(new Error('å¯ç éå
å«åæ¯ãæ°ååç¹æ®å符ä¸çè³å°ä¸¤ç§')) |
| | | } else { |
| | | callback() // éªè¯éè¿ |
| | | } |
| | | } |
| | | }, |
| | | /** |
| | | * æå¼çªå£ |
| | | * |
| | |
| | | import com.doumee.biz.system.SystemUserBiz; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.utils.PwdCheckUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.system.dto.CreateSystemUserDTO; |
| | | import com.doumee.dao.system.dto.CreateUserRoleDTO; |
| | |
| | | |
| | | @Override |
| | | public void updatePwd(UpdatePwdDto dto) { |
| | | if(StringUtils.isBlank(dto.getNewPwd()) |
| | | ||dto.getNewPwd().length()>20 |
| | | ||dto.getNewPwd().length()<6 |
| | | ||!PwdCheckUtil.checkPassword(dto.getNewPwd())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对ä¸èµ·ï¼å¯ç å¤æåº¦ä¸æ»¡è¶³è¦æ±ï¼6-20个å符ï¼è³å°å
å«åæ¯ãæ°ååç¹æ®å符2ç§"); |
| | | } |
| | | SystemUser user = systemUserService.findById(dto.getUserId()); |
| | | if (user.getDeleted()) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "ç¨æ·ä¸åå¨æå·²è¢«å é¤"); |
| | |
| | | |
| | | @Override |
| | | public void resetPwd(ResetSystemUserPwdDTO dto) { |
| | | if(StringUtils.isBlank(dto.getPassword()) |
| | | ||dto.getPassword().length()>20 |
| | | ||dto.getPassword().length()<6 |
| | | ||!PwdCheckUtil.checkPassword(dto.getPassword())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对ä¸èµ·ï¼å¯ç å¤æåº¦ä¸æ»¡è¶³è¦æ±ï¼6-20个å符ï¼è³å°å
å«åæ¯ãæ°ååç¹æ®å符2ç§"); |
| | | } |
| | | // æ¥è¯¢ç¨æ· |
| | | SystemUser systemUser = systemUserService.findById(dto.getId()); |
| | | if (systemUser == null || systemUser.getDeleted()) { |
| | |
| | | @Override |
| | | @Transactional |
| | | public void create(CreateSystemUserDTO systemUser) { |
| | | if(StringUtils.isBlank(systemUser.getPassword()) |
| | | ||systemUser.getPassword().length()>20 |
| | | ||systemUser.getPassword().length()<6 |
| | | ||!PwdCheckUtil.checkPassword(systemUser.getPassword())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对ä¸èµ·ï¼å¯ç å¤æåº¦ä¸æ»¡è¶³è¦æ±ï¼6-20个å符ï¼è³å°å
å«åæ¯ãæ°ååç¹æ®å符2ç§"); |
| | | } |
| | | // éªè¯ç¨æ·å |
| | | SystemUser queryUserDto = new SystemUser(); |
| | | queryUserDto.setUsername(systemUser.getUsername()); |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "å·¥å·å·²åå¨"); |
| | | } |
| | | } |
| | | |
| | | // çæå¯ç ç |
| | | String salt = RandomStringUtils.randomAlphabetic(6); |
| | | // çæå¯ç |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.utils; |
| | | |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * Javaæ£åæ ¡éªå¯ç è³å°å
å«ï¼åæ¯æ°åç¹æ®ç¬¦å·ä¸ç2ç§ |
| | | */ |
| | | public class PwdCheckUtil { |
| | | |
| | | /** |
| | | * åå®è®¾ç½®å¯ç æ¶ï¼å¯ç è§åä¸ºï¼ åæ¯ãæ°åãç¹æ®ç¬¦å·ï¼è³å°å¹é
2ç§ |
| | | * åå¯ç å¯è½åºç°çæ
åµæï¼ |
| | | * 1ãæ°å+ç¹æ®ç¬¦å· |
| | | * 2ã忝+ç¹æ®ç¬¦å· |
| | | * 3ã忝+æ°å |
| | | * 4ã忝+æ°å+ç¹æ®ç¬¦å· |
| | | * (ç»åä¸é¡ºåºæ å
³) |
| | | * è§£å³æè·¯ï¼ |
| | | * 1ãéåå符串çå符æ°ç»ï¼æ¥çæ¯å¦å
å«ç®æ ç¹æ®å符ï¼è¥å
å«ï¼åæ è®°å符串 |
| | | * å
å«ç¹æ®å符ï¼å¹¶æ¿æ¢å½åç¹æ®å符为''ã |
| | | * 2ã夿å©ä¸çåç¬¦ç»æçåç¬¦ä¸²ï¼æ¯å¦å¹é
以䏿
åµ |
| | | * - çº¯åæ¯ |
| | | * - 纯æ°å |
| | | * - 忝+æ°å |
| | | * 3ãå符串å¹é
è§å |
| | | * çº¯åæ¯+å
å«ç¹æ®å符 ---- å¹é
éè¿ |
| | | * 纯æ°å+å
å«ç¹æ®å符 ---- å¹é
éè¿ |
| | | * 忝+æ°å+å
å«ä¸ªæ°å符 ---- å¹é
éè¿ |
| | | */ |
| | | //ç¹æ®å符 |
| | | public static final String SPEC_CHARACTERS = " !\"#$%&'()*+,-./:;<=>?@\\]\\[^_`{|}~"; |
| | | // çº¯åæ¯ |
| | | public static final String character = "[a-zA-Z]{1,}$"; |
| | | // 纯æ°å |
| | | public static final String numberic = "[0-9]{1,}$"; |
| | | // 忝忰å |
| | | public static final String number_and_character = "((^[a-zA-Z]{1,}[0-9]{1,}[a-zA-Z0-9]*)+)" + |
| | | "|((^[0-9]{1,}[a-zA-Z]{1,}[a-zA-Z0-9]*)+)$"; |
| | | // åæ¯ææ°å |
| | | public static final String number_or_character = "[a-zA-Z0-9]+$"; |
| | | // 忝æ°åä¸å线 |
| | | public static final String ncw = "\\w+$"; |
| | | |
| | | public static boolean checkPassword(String targetString) { |
| | | String opStr = targetString; |
| | | boolean isLegal = false; |
| | | boolean hasSpecChar = false; |
| | | char[] charArray = opStr.toCharArray(); |
| | | for (char c : charArray) { |
| | | if (SPEC_CHARACTERS.contains(String.valueOf(c))) { |
| | | hasSpecChar = true; |
| | | // æ¿æ¢æ¤å符串 |
| | | opStr = opStr.replace(c, ' '); |
| | | } |
| | | } |
| | | String excSpecCharStr = opStr.replace(" ", ""); |
| | | boolean isPureNum = Pattern.compile(numberic).matcher(excSpecCharStr).matches(); |
| | | boolean isPureChar = Pattern.compile(character).matcher(excSpecCharStr).matches(); |
| | | boolean isNumAndChar = Pattern.compile(number_and_character).matcher(excSpecCharStr).matches(); |
| | | isLegal = ((isPureNum && hasSpecChar) |
| | | || (isPureChar && hasSpecChar) || isNumAndChar && hasSpecChar) || isNumAndChar; |
| | | System.out.println("å符串ï¼" + targetString + ",æ¯å¦ç¬¦åè§åï¼" + isLegal); |
| | | System.out.println("---------------"); |
| | | return isLegal; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | checkPassword("123456a"); |
| | | // checkPassword("41234123"); |
| | | // checkPassword("#$%^&&*("); |
| | | // checkPassword("fasd$$"); |
| | | // checkPassword("41234%%%"); |
| | | // checkPassword("fasd41^(324"); |
| | | // checkPassword("fa413%^&*"); |
| | | // checkPassword("&%fa413%^&*"); |
| | | } |
| | | |
| | | } |