Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sass-admin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj_app
sass-admin
Commits
4d43a812
Commit
4d43a812
authored
Jun 12, 2025
by
end
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化修改密码
parent
6f4bb144
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
56 deletions
+74
-56
dist.zip
+0
-0
src/pages/SystemManagement/Organization/EditPassword/EditPassword.jsx
+74
-56
No files found.
dist.zip
View file @
4d43a812
No preview for this file type
src/pages/SystemManagement/Organization/EditPassword/EditPassword.jsx
View file @
4d43a812
...
...
@@ -14,7 +14,7 @@ const FormItem = Form.Item;
import
moment
from
'moment'
import
md5
from
"md5"
;
import
intl
from
"react-intl-universal"
;
import
{
sm2
}
from
"sm-crypto"
;
class
EditPassword
extends
Component
{
constructor
(
props
)
{
super
(
props
);
...
...
@@ -26,12 +26,11 @@ class EditPassword extends Component {
generateCharacter
(
n
){
var
chars
=
[
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
,
'P'
,
'Q'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
]
var
res
=
""
;
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
var
id
=
Math
.
ceil
(
Math
.
random
()
*
35
);
res
+=
chars
[
id
];
}
return
res
;
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
var
id
=
Math
.
ceil
(
Math
.
random
()
*
35
);
res
+=
chars
[
id
];
}
return
res
;
}
getCurrentDay
(){
...
...
@@ -40,56 +39,72 @@ class EditPassword extends Component {
return
date
}
handleSubmit
=
e
=>
{
// e.preventDefault();
this
.
props
.
form
.
validateFields
((
err
,
values
)
=>
{
if
(
err
)
return
;
else
{
//因为后台需要传一个字段
let
{
id
,
password
}
=
values
;
const
public_key
=
'047214fe3a249b75b6ba92ee494e0a8a68c0a19893a480b3c28bf06cd5b7d621243c7f6704caa3b43ade6be15de11cabd185611a9edfdcf1b11d7a2478c67b4c1c'
const
private_key
=
'00a2bbe941a177ca9f200d1c4d37e8f0b43b9cd2ea662304a05c064c6416e74d49'
let
salt
=
""
let
date
=
""
let
key
=
""
let
sign
=
""
let
newPassword
=
""
let
requestId
=
""
salt
=
this
.
generateCharacter
(
16
)
console
.
log
(
"validate-salt"
,
salt
)
date
=
this
.
getCurrentDay
()
console
.
log
(
"validate-date"
,
date
)
newPassword
=
sm2
.
doEncrypt
(
password
+
salt
,
public_key
,
1
);
requestId
=
sm2
.
doEncrypt
(
id
+
salt
,
public_key
,
1
)
newPassword
=
"04"
+
newPassword
requestId
=
"04"
+
requestId
if
(
salt
&&
date
){
key
=
salt
+
date
console
.
log
(
"validate-key"
,
key
)
}
sign
=
"id="
+
requestId
+
"&password="
+
newPassword
+
"&salt="
+
salt
+
"&key="
+
key
console
.
log
(
"validate-sign"
,
md5
(
sign
))
let
parms
=
{
id
:
requestId
,
password
:
newPassword
,
salt
:
salt
,
sign
:
md5
(
sign
)
}
// let passwordVal = { id, password };
this
.
props
.
accountUpdatePassword
(
parms
);
//关闭模态框
handleSubmit
=
async
e
=>
{
try
{
// e.preventDefault();
if
(
!
this
.
props
.
form
)
{
console
.
error
(
'表单实例未正确传递'
);
return
;
}
if
(
!
sm2
)
{
console
.
error
(
'sm2 库未正确引入'
);
return
;
}
const
validationResult
=
await
new
Promise
((
resolve
)
=>
{
this
.
props
.
form
.
validateFields
((
err
,
values
)
=>
{
resolve
({
err
,
values
});
});
});
if
(
validationResult
.
err
)
{
console
.
error
(
'表单验证失败:'
,
validationResult
.
err
);
return
;
}
const
{
id
,
password
}
=
validationResult
.
values
;
const
public_key
=
'047214fe3a249b75b6ba92ee494e0a8a68c0a19893a480b3c28bf06cd5b7d621243c7f6704caa3b43ade6be15de11cabd185611a9edfdcf1b11d7a2478c67b4c1c'
;
const
private_key
=
'00a2bbe941a177ca9f200d1c4d37e8f0b43b9cd2ea662304a05c064c6416e74d49'
;
const
salt
=
this
.
generateCharacter
(
16
);
console
.
log
(
"validate-salt"
,
salt
);
const
date
=
this
.
getCurrentDay
();
console
.
log
(
"validate-date"
,
date
);
const
newPassword
=
"04"
+
sm2
.
doEncrypt
(
password
+
salt
,
public_key
,
1
);
const
requestId
=
"04"
+
sm2
.
doEncrypt
(
id
+
salt
,
public_key
,
1
);
const
key
=
salt
+
date
;
console
.
log
(
"validate-key"
,
key
);
const
sign
=
`id=
${
requestId
}
&password=
${
newPassword
}
&salt=
${
salt
}
&key=
${
key
}
`
;
console
.
log
(
"validate-sign"
,
md5
(
sign
));
const
parms
=
{
id
:
requestId
,
password
:
newPassword
,
salt
:
salt
,
sign
:
md5
(
sign
)
};
if
(
typeof
this
.
props
.
accountUpdatePassword
!==
'function'
)
{
console
.
error
(
'accountUpdatePassword 不是一个函数'
);
return
;
}
await
this
.
props
.
accountUpdatePassword
(
parms
);
// 关闭模态框
if
(
typeof
this
.
props
.
onCancel
===
'function'
)
{
this
.
props
.
onCancel
(
false
);
}
});
}
catch
(
error
)
{
console
.
error
(
'处理提交时发生错误:'
,
error
);
// 可以添加错误提示给用户
}
};
validateToNextPassword
=
(
rule
,
value
,
callback
)
=>
{
const
form
=
this
.
props
.
form
;
if
(
value
&&
this
.
state
.
confirmDirty
)
{
...
...
@@ -97,10 +112,12 @@ class EditPassword extends Component {
}
callback
();
};
handleConfirmBlur
=
e
=>
{
const
value
=
e
.
target
.
value
;
this
.
setState
({
confirmDirty
:
this
.
state
.
confirmDirty
||
!!
value
});
};
compareToFirstPassword
=
(
rule
,
value
,
callback
)
=>
{
const
form
=
this
.
props
.
form
;
if
(
value
&&
value
!==
form
.
getFieldValue
(
"password"
))
{
...
...
@@ -109,12 +126,13 @@ class EditPassword extends Component {
callback
();
}
};
render
()
{
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
//获取当前这一行的属性
//
获取当前这一行的属性
let
{
editeData
}
=
this
.
props
;
console
.
log
(
editeData
);
const
remarkStyle
=
{
//bug-12732-liyuan
const
remarkStyle
=
{
//
bug-12732-liyuan
marginBottom
:
0
,
lineHeight
:
'1.8'
,
fontSize
:
'12px'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment