add password validate

This commit is contained in:
zhiqiang feng
2022-09-21 16:09:27 +08:00
parent ba185bd4eb
commit e5bb57a1ac
+25
View File
@@ -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;
}
}