Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangqinghua
smart
Commits
921c2e94
Commit
921c2e94
authored
Dec 10, 2019
by
wangqinghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1fe82deb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
8 deletions
+42
-8
modify-password.component.ts
...pp/app/modal/modify-password/modify-password.component.ts
+42
-8
No files found.
src/main/webapp/app/modal/modify-password/modify-password.component.ts
View file @
921c2e94
...
...
@@ -4,6 +4,8 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import
{
NzMessageComponent
,
NzMessageService
}
from
'ng-zorro-antd'
;
import
{
LayoutService
}
from
'../../layouts/layout.service'
;
import
{
LoginService
}
from
'../../shared'
;
import
{
Base64
}
from
'js-base64'
;
import
{
LocalStorageService
}
from
'ngx-webstorage'
;
@
Component
({
selector
:
'smart-modify-password'
,
...
...
@@ -16,11 +18,14 @@ export class ModifyPasswordComponent implements OnInit {
isOkLoading
=
false
;
title
=
'修改密码'
;
validateForm
:
FormGroup
;
reg
=
new
RegExp
(
/^
(?=[
a-zA-Z
]
+
\d
+
)\w{8,20}
$/
);
groupid
;
constructor
(
private
fb
:
FormBuilder
,
private
layoutSer
:
LayoutService
,
private
message
:
NzMessageService
,
private
loginService
:
LoginService
)
{}
private
$localStorage
:
LocalStorageService
,
private
message
:
NzMessageService
,
private
loginService
:
LoginService
)
{
}
ngOnInit
()
{
this
.
initForm
();
...
...
@@ -38,18 +43,47 @@ export class ModifyPasswordComponent implements OnInit {
if
(
this
.
validateForm
.
invalid
)
{
return
false
;
}
if
(
this
.
validateForm
.
value
.
newPassword
!=
this
.
validateForm
.
value
.
realPassword
)
{
this
.
message
.
error
(
"两次输入密码不一致"
);
if
(
this
.
validateForm
.
value
.
newPassword
!=
this
.
validateForm
.
value
.
realPassword
)
{
this
.
message
.
error
(
'两次输入密码不一致'
);
return
false
;
}
this
.
isOkLoading
=
true
;
this
.
update
();
this
.
getOldEncodepassword
();
}
//获取旧密码加密
getOldEncodepassword
()
{
const
data
=
{
userName
:
this
.
$localStorage
.
retrieve
(
'userInfo'
).
userName
,
password
:
Base64
.
encode
(
this
.
validateForm
.
value
.
oldPassword
)
};
this
.
layoutSer
.
encodePassword
(
data
).
subscribe
(
(
res
)
=>
{
this
.
validateForm
.
patchValue
({
oldPassword
:
res
.
data
});
this
.
getNewEncodepassword
();
}
);
}
//获取新密码加密
getNewEncodepassword
()
{
const
data
=
{
userName
:
this
.
$localStorage
.
retrieve
(
'userInfo'
).
userName
,
password
:
Base64
.
encode
(
this
.
validateForm
.
value
.
realPassword
)
};
this
.
layoutSer
.
encodePassword
(
data
).
subscribe
(
(
res
)
=>
{
this
.
validateForm
.
patchValue
({
realPassword
:
res
.
data
});
this
.
validateForm
.
patchValue
({
newPassword
:
res
.
data
});
this
.
update
();
}
);
}
update
()
{
let
formData
=
new
FormData
();
formData
.
append
(
'newPassword'
,
this
.
validateForm
.
value
.
realPassword
);
formData
.
append
(
'oldPassword'
,
this
.
validateForm
.
value
.
oldPassword
);
formData
.
append
(
'newPassword'
,
this
.
validateForm
.
value
.
realPassword
);
formData
.
append
(
'oldPassword'
,
this
.
validateForm
.
value
.
oldPassword
);
this
.
layoutSer
.
modifyPassword
(
formData
).
subscribe
(
(
res
)
=>
{
if
(
res
.
errCode
==
10000
)
{
...
...
@@ -72,8 +106,8 @@ export class ModifyPasswordComponent implements OnInit {
initForm
()
{
this
.
validateForm
=
this
.
fb
.
group
({
oldPassword
:
[
null
,
[
Validators
.
required
]],
newPassword
:
[
null
,
[
Validators
.
required
,
Validators
.
minLength
(
6
),
Validators
.
maxLength
(
12
)]],
realPassword
:
[
null
,
[
Validators
.
required
,
Validators
.
minLength
(
6
),
Validators
.
maxLength
(
12
)]],
newPassword
:
[
null
,
[
Validators
.
required
,
Validators
.
minLength
(
6
),
Validators
.
maxLength
(
12
)]],
realPassword
:
[
null
,
[
Validators
.
required
,
Validators
.
minLength
(
6
),
Validators
.
maxLength
(
12
)]],
});
}
}
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