From 1ca1efc184574a932d1d97605b554abbde5824a7 Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Mon, 26 Feb 2018 17:20:41 +0800
Subject: [PATCH] BUGFIX-176
---
src/app/routes/passport/login/login.component.ts | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/app/routes/passport/login/login.component.ts b/src/app/routes/passport/login/login.component.ts
index c55479e..b4739c1 100644
--- a/src/app/routes/passport/login/login.component.ts
+++ b/src/app/routes/passport/login/login.component.ts
@@ -7,11 +7,12 @@
import { NzMessageService } from 'ng-zorro-antd';
import { SocialService, SocialOpenType, ITokenService, DA_SERVICE_TOKEN } from '@delon/auth';
import { environment } from '@env/environment';
+import { CookieService } from 'angular2-cookie/services/cookies.service';
@Component({
selector: 'passport-login',
templateUrl: './login.component.html',
styleUrls: [ './login.component.less' ],
- providers: [ SocialService]
+ providers: [ SocialService,CookieService]
})
export class UserLoginComponent implements OnDestroy {
@@ -27,6 +28,7 @@
private settingsService: SettingsService,
private socialService: SocialService,
private loginService:LoginService,
+ private _cookieService:CookieService,
@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) {
this.form = fb.group({
userName: [null, [Validators.required, Validators.minLength(5)]],
@@ -35,6 +37,9 @@
captcha: [null, [Validators.required]],
remember: [true]
});
+ let nowTime = new Date();
+ nowTime.setDate(nowTime.getDate()+1);
+ this._cookieService.put('test','test',{expires:nowTime});
}
// region: fields
@@ -86,12 +91,12 @@
name: this.userName.value,
time: +new Date
});
- this.validateError = true;
+ this.validateError = {};
this.router.navigate(['/']);
}
},
(err) => {
- console.log(err);
+ // console.log(err);
if(err instanceof ProgressEvent){
const error = <ProgressEvent>err;
let xmlHttp = error.target;
@@ -100,8 +105,11 @@
console.log(xmlHttpRequest.response);
const response = JSON.parse(xmlHttpRequest.response);
if(response.status == 401&&response.errorCode==10){
- this.validateError = true;
+ this.validateError["password_incorrect"]=true;
this.loading = false;
+ } else if(response.status == 401&&response.errorCode==12) {
+ this.validateError["account_expired"]=true;
+ this.loading = false;
}
}
}
@@ -109,7 +117,7 @@
);
}
- public validateError:boolean;
+ public validateError:{[s:string]:boolean} = {};
// region: social
open(type: string, openType: SocialOpenType = 'href') {
--
Gitblit v1.8.0