diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index ee164a5..e352294 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -39,7 +39,13 @@ export class LoginComponent implements OnInit { if (xhr.is_success) { sessionStorage.setItem('userInfo', JSON.stringify(xhr.body)); this.message.success('登录成功!'); - this.router.navigate(['../app/main'], { relativeTo: this.route }); + // 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; + } }