Commit 9d88a285 authored by 李纪文's avatar 李纪文

fix: 修改密码验证

parent aec842ea
...@@ -177,6 +177,7 @@ ...@@ -177,6 +177,7 @@
"react-redux": "^8.0.5", "react-redux": "^8.0.5",
"react-resizable": "^3.0.4", "react-resizable": "^3.0.4",
"sha1": "^1.1.1", "sha1": "^1.1.1",
"js-sha256": "^0.10.1",
"rc-resize-observer": "1.4.0", "rc-resize-observer": "1.4.0",
"react-window": "1.8.9" "react-window": "1.8.9"
}, },
......
...@@ -50,6 +50,7 @@ import { ...@@ -50,6 +50,7 @@ import {
stationData, stationData,
getVideoUrl, getVideoUrl,
loginauthen, loginauthen,
encipher,
} from './js/utils'; } from './js/utils';
import './index.less'; import './index.less';
...@@ -1278,7 +1279,7 @@ const ConfigurationView = (props) => { ...@@ -1278,7 +1279,7 @@ const ConfigurationView = (props) => {
mqttView && mqttView &&
mqttView.onSendWaMessageArrived( mqttView.onSendWaMessageArrived(
userName, userName,
sha1(password).toUpperCase(), encipher(password).toUpperCase(),
guid, guid,
code, code,
tag, tag,
......
import { authorizationToken } from '../apis'; import { authorizationToken } from '../apis';
import sha1 from 'sha1';
import { sha256, sha224 } from 'js-sha256';
// 判断是否是数字 // 判断是否是数字
export const isNumber = (val) => { export const isNumber = (val) => {
...@@ -154,7 +156,10 @@ export const stationData = [ ...@@ -154,7 +156,10 @@ export const stationData = [
export const getVideoUrl = () => { export const getVideoUrl = () => {
const protocol = window.location.protocol; const protocol = window.location.protocol;
const address = protocol === "https:" ? window.location.origin.replace(protocol, 'wss:') : window.location.origin.replace(protocol, 'ws:'); const address =
protocol === 'https:'
? window.location.origin.replace(protocol, 'wss:')
: window.location.origin.replace(protocol, 'ws:');
return `${address}/`; return `${address}/`;
}; };
...@@ -187,3 +192,21 @@ export const queryProduct = (data, url) => { ...@@ -187,3 +192,21 @@ export const queryProduct = (data, url) => {
} }
return res; return res;
}; };
export const encipher = (password, type) => {
let code = '';
if (!password) return code;
const wordtype = type || window?.globalConfig?.encrypt || 'SHA1';
switch (wordtype) {
case 'SHA1':
code = sha1(password);
break;
case 'SHA256':
code = sha256(password);
break;
default:
code = sha1(password);
break;
}
return code;
};
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