add password validate
This commit is contained in:
@@ -39,7 +39,13 @@ export class LoginComponent implements OnInit {
|
||||
if (xhr.is_success) {
|
||||
sessionStorage.setItem('userInfo', JSON.stringify(xhr.body));
|
||||
this.message.success('登录成功!');
|
||||
// console.log(sessionStorage.getItem('userInfo'));
|
||||
if (this.checkPattern(this.loginForm.controls['password'].value)) {
|
||||
this.router.navigate(['../app/main'], { relativeTo: this.route });
|
||||
} else {
|
||||
this.message.error('请修改用户密码');
|
||||
this.router.navigate(['/chpw']);
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -49,4 +55,23 @@ export class LoginComponent implements OnInit {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
checkPattern(pw: string): boolean {
|
||||
if (pw.length < 8) {
|
||||
return false;
|
||||
}
|
||||
if (!/\d/.test(pw)) {
|
||||
return false;
|
||||
}
|
||||
if (!/[A-Z]/.test(pw)) {
|
||||
return false;
|
||||
}
|
||||
if (!/[a-z]/.test(pw)) {
|
||||
return false;
|
||||
}
|
||||
if (!/[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(pw)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user