|
|
|
@@ -1,5 +1,7 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { AuthService } from '../services/auth.service'; |
|
|
|
import { ToastService } from '../services/toast.service'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-login', |
|
|
|
@@ -8,14 +10,17 @@ import { Router } from '@angular/router'; |
|
|
|
}) |
|
|
|
export class LoginPage implements OnInit { |
|
|
|
credentials = { |
|
|
|
email: null, |
|
|
|
password: null |
|
|
|
} |
|
|
|
username: 'rakeshsrh', |
|
|
|
password: '123456789', |
|
|
|
login_type: 'user' |
|
|
|
}; |
|
|
|
|
|
|
|
show_password = false; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private router: Router |
|
|
|
private router: Router, |
|
|
|
private authService: AuthService, |
|
|
|
public toastService: ToastService |
|
|
|
) { } |
|
|
|
|
|
|
|
ionViewDidEnter() { |
|
|
|
@@ -30,8 +35,15 @@ export class LoginPage implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
login() { |
|
|
|
this.router.navigate(['/malls']); |
|
|
|
document.querySelector('.menu-icon-holder').classList.remove('hide'); |
|
|
|
this.authService.authenticateUser(this.credentials).then((data: any) => { |
|
|
|
localStorage.userInfo = data; |
|
|
|
localStorage.access_Token = data.access_Token; |
|
|
|
this.router.navigate(['/malls']); |
|
|
|
document.querySelector('.menu-icon-holder').classList.remove('hide'); |
|
|
|
}, (err) => { |
|
|
|
console.log(err); |
|
|
|
this.toastService.presentToast('Please check your credentials', 'danger'); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} |