edit login token

vacation-rule^2
Mohamed Mekawy 6 years ago
parent fee59fb259
commit 5d41967ed7

@ -45,7 +45,7 @@ export class LoginComponent implements OnInit, OnDestroy {
public loginDiv:boolean =true; public loginDiv:boolean =true;
public welcomeBack:boolean =false; public welcomeBack:boolean =false;
public logo = "assets/icon/login/password.png"; public logo = "assets/icon/login/password.png";
deviceToken: any; deviceToken: any="";
user: boolean =false; user: boolean =false;
DeviceType: string; DeviceType: string;
requestGetLoginInfo:any; requestGetLoginInfo:any;
@ -67,10 +67,35 @@ export class LoginComponent implements OnInit, OnDestroy {
) { } ) { }
ngOnInit() { ngOnInit() {
this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); // this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
console.log("get deviceToken login"+ this.deviceToken) // console.log("get deviceToken login"+ this.deviceToken)
this.deviceToken= localStorage.getItem('devicyeToken');
console.log("let deviceToken" + this.deviceToken);
if (this.deviceToken) {
console.log('login enabled first time: ' + this.deviceToken);
} else {
console.log("no deviceToken" );
this.pushService.startReceiving();
setTimeout(() => {
this.deviceToken= localStorage.getItem('deviceToken');
console.log('login enabled second time: ' + this.deviceToken);
}, 1000);
}
setTimeout(() => {
this.getLastLoginInfo();
},5000);
this.getLastLoginInfo();
//here will delete below part and depdding on user (response from getMobileInfo) //here will delete below part and depdding on user (response from getMobileInfo)
this.username = localStorage.getItem("user"); this.username = localStorage.getItem("user");
this.password = localStorage.getItem("password"); //****// this.password = localStorage.getItem("password"); //****//
@ -143,20 +168,20 @@ export class LoginComponent implements OnInit, OnDestroy {
// this.checkAppUpdated(); // this.checkAppUpdated();
// this.checkUserAuthentication(); // this.checkUserAuthentication();
let deviceToken = localStorage.getItem('deviceToken'); this.deviceToken = localStorage.getItem('deviceToken');
console.log("let deviceToken" + deviceToken); console.log("let deviceToken" + this.deviceToken);
if (deviceToken) { if (this.deviceToken) {
console.log('login enabled first time: ' + deviceToken); console.log('login enabled first time: ' + this.deviceToken);
this.checkAppUpdated(); this.checkAppUpdated();
} else { } else {
console.log("no deviceToken" ); console.log("no deviceToken" );
this.pushService.startReceiving(); this.pushService.startReceiving();
setTimeout(() => { setTimeout(() => {
deviceToken = localStorage.getItem('deviceToken'); this.deviceToken = localStorage.getItem('deviceToken');
this.checkAppUpdated(); this.checkAppUpdated();
console.log('login enabled second time: ' + deviceToken); console.log('login enabled second time: ' + this.deviceToken);
}, 1000); }, 1000);
} }
} }
@ -329,7 +354,6 @@ export class LoginComponent implements OnInit, OnDestroy {
/// ///
getLastLoginInfo(){ getLastLoginInfo(){
this.deviceToken
this.requestGetLoginInfo= { this.requestGetLoginInfo= {
DeviceType:this.cs.getDeviceType(), DeviceType:this.cs.getDeviceType(),
DeviceToken:this.deviceToken//"5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken DeviceToken:this.deviceToken//"5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken

@ -166,6 +166,7 @@ export class PushService {
if (data) { if (data) {
this.cs.sharedService.setSharedData(data, AuthenticationService.DEVICE_TOKEN); this.cs.sharedService.setSharedData(data, AuthenticationService.DEVICE_TOKEN);
localStorage.setItem('deviceToken', data); localStorage.setItem('deviceToken', data);
} }
if (this.authService.isAuthenticated()) { if (this.authService.isAuthenticated()) {
this.registerAuthenticatedUser(data); this.registerAuthenticatedUser(data);
@ -249,4 +250,7 @@ export class PushService {
} }

Loading…
Cancel
Save