提交 0862669d authored 作者: 钟是志's avatar 钟是志

解决安全漏洞问题. 保证用户输入的新密码至少包含数字和字符 且不少于8位

上级 2e9a8cd2
......@@ -2,18 +2,18 @@
* 一站式正在使用此文件
* 请谨慎使用
* */
import React from 'react';
import moment from 'moment';
import { Icon, message, notification } from 'antd';
import { getOnestopKey } from '../../Services';
import FormdataWrapper from './object-to-formdata-custom';
import React from "react";
import moment from "moment";
import { Icon, message, notification } from "antd";
import { getOnestopKey } from "../../Services";
import FormdataWrapper from "./object-to-formdata-custom";
let messageTime = new Date().getTime() - 3000;
/**
* 校验 开始时间必须在结束时间之前的函数
* */
export function checkDate(endTime = '2019-01-01', startTime = '2018-12-31') {
export function checkDate(endTime = "2019-01-01", startTime = "2018-12-31") {
return moment(endTime).isAfter(moment(startTime));
}
......@@ -22,15 +22,15 @@ export function checkDate(endTime = '2019-01-01', startTime = '2018-12-31') {
* */
export function matchReg(str) {
let reg = /<\/?.+?\/?>/g;
return str.replace(reg, '').replace(/&nbsp;/g, ' ');
return str.replace(reg, "").replace(/&nbsp;/g, " ");
}
export function htmlFormat(str) {
if (typeof str !== 'string') {
return '';
if (typeof str !== "string") {
return "";
}
const newTxt = str.replace(/\s+([^<>]+)(?=<)/g, function(match) {
return match.replace(/\s/g, '&nbsp;');
return match.replace(/\s/g, "&nbsp;");
});
return newTxt;
}
......@@ -40,11 +40,11 @@ export function countSpecialField(filedSpanBig, nameSpanBig) {
if (document.body.clientWidth > 1400) {
if (filedSpanBig === 5) {
// 当设置一行排列5个字段时 自定义宽度为20%
style = { width: '20%' };
style = { width: "20%" };
}
if (filedSpanBig === 1 && nameSpanBig === 2) {
// 当一行显示一个字段 然后名字又特别长时 使用这个width
style = { width: '6%' };
style = { width: "6%" };
}
}
return style;
......@@ -57,7 +57,7 @@ export function deepCopy(obj, parent = null) {
if (React.isValidElement(obj)) {
return React.cloneElement(obj);
}
if (['boolean', 'string', 'number'].indexOf(typeof obj) > -1 || !obj) {
if (["boolean", "string", "number"].indexOf(typeof obj) > -1 || !obj) {
return obj;
}
let result;
......@@ -83,12 +83,12 @@ export function deepCopy(obj, parent = null) {
key = keys[i];
temp = obj[key];
// 如果字段的值也是一个对象
if (temp && typeof temp === 'object') {
if (temp && typeof temp === "object") {
// 递归执行深拷贝 将同级的待拷贝对象与新对象传递给 parent 方便追溯循环引用
result[key] = deepCopy(temp, {
originalParent: obj,
currentParent: result,
parent: parent,
parent: parent
});
} else {
result[key] = temp;
......@@ -108,20 +108,20 @@ export function getFormElemValue(type, e, other) {
let value = e;
switch (type) {
case 'input':
case "input":
value = e.target.value;
break;
case 'checkbox':
case "checkbox":
value = e.target.checked;
break;
case 'textarea':
case "textarea":
value = e.target.value;
break;
case 'buttonUpload':
case "buttonUpload":
value = e.url;
break;
case 'upload':
value = Array.isArray(e) ? e.join(',') : '';
case "upload":
value = Array.isArray(e) ? e.join(",") : "";
break;
default:
break;
......@@ -140,10 +140,10 @@ export function randomStr() {
}
export function isJSON(str) {
if (typeof str == 'string') {
if (typeof str == "string") {
try {
JSON.parse(str);
if (typeof JSON.parse(str) === 'number') {
if (typeof JSON.parse(str) === "number") {
return false;
}
return true;
......@@ -199,12 +199,12 @@ export function displayRender(label) {
if (label && label.length) {
return label[label.length - 1];
} else {
return '';
return "";
}
}
export function isEmptyValue(value) {
return typeof value === 'undefined' || value === null || value === '';
return typeof value === "undefined" || value === null || value === "";
}
// 全局的通知消息组件
......@@ -216,25 +216,25 @@ export function controlNotification(props) {
messageTime = nowTime;
notification.info({
...props,
icon: <Icon type="info-circle" style={{ color: '#fa8c16' }} />,
icon: <Icon type="info-circle" style={{ color: "#fa8c16" }} />
});
return true;
}
export function setOneStopConfig(value) {
if (typeof value !== 'string') {
if (typeof value !== "string") {
value = JSON.stringify(value);
}
localStorage.setItem('oneStopConfig', value);
localStorage.setItem("oneStopConfig", value);
}
export function getOneStopConfig(key) {
let configList = localStorage.getItem('oneStopConfig');
let configList = localStorage.getItem("oneStopConfig");
if (configList && isJSON(configList)) {
let data = JSON.parse(configList);
if (data && typeof data === 'object') {
if (typeof data === 'undefined') {
return '';
if (data && typeof data === "object") {
if (typeof data === "undefined") {
return "";
}
return data[key] || false;
}
......@@ -257,13 +257,13 @@ export function diGuiTree(treeData = [], i = 0) {
}
export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx') {
export function downloadFile(url, params, fileName = "导出文件", ext = "xlsx") {
fetch(url, {
method: 'POST',
body: FormdataWrapper(params),
method: "POST",
body: FormdataWrapper(params)
})
.then((res) => {
if (res.status + '' !== '200') {
if (res.status + "" !== "200") {
return res.json();
} else {
return res.blob();
......@@ -271,9 +271,9 @@ export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx
})
.then((data) => {
if (data instanceof Blob) {
let a = document.createElement('a');
let a = document.createElement("a");
let url = window.URL.createObjectURL(data);
let filename = fileName + '.' + ext;
let filename = fileName + "." + ext;
a.href = url;
a.download = filename;
a.click();
......@@ -282,16 +282,47 @@ export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx
} else {
notification.error({
message: `文件导出错误`,
description: data.errMsg,
description: data.errMsg
});
}
})
.catch((err) => {
notification.error({
message: `网络请求超时`,
message: `网络请求超时`
});
})
.finally(() => {
return true;
});
}
export default function CheckPassWord(password = "") {
console.log(password);
if (!password || password.length < 8) {
// message.warning("密码过于简单, 请输入不小于8位的密码 且必须包含数字和字母!");
console.log('位数不够');
return false;
}
let includeNumber = false;
let includeWord = false;
for (let i = 0; i <= password.length; i++) {
let iN = password.charCodeAt(i);
//数字
if (iN >= 48 && iN <= 57) {
includeNumber = true;
}
// 大写 // 小写
if ((iN >= 65 && iN <= 90) || (iN >= 97 && iN <= 122)) {
includeWord = true;
}
if(includeWord && includeNumber){
return true;
}
}
if(includeWord && includeNumber){
}else{
// message.warning("密码过于简单, 请输入不小于8位的密码 且必须包含数字和字母!");
return false;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论