|
|
@@ -1,5 +1,6 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { AuthService } from '../services/auth.service'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-login', |
|
|
@@ -7,17 +8,31 @@ import { Router } from '@angular/router'; |
|
|
|
styleUrls: ['./login.component.scss'] |
|
|
|
}) |
|
|
|
export class LoginComponent implements OnInit { |
|
|
|
credentials = { |
|
|
|
username: '', |
|
|
|
password: '' |
|
|
|
}; |
|
|
|
|
|
|
|
errorMessage: string = ''; |
|
|
|
|
|
|
|
constructor( |
|
|
|
public router: Router |
|
|
|
public router: Router, |
|
|
|
private authService: AuthService |
|
|
|
) { } |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
} |
|
|
|
|
|
|
|
authenticateUser() { |
|
|
|
localStorage.vendor_token = 'a'; |
|
|
|
this.router.navigate(['shop-details']); |
|
|
|
requestAuthentication() { |
|
|
|
this.authService.authenticateUser(this.credentials).then((data: any) => { |
|
|
|
localStorage.vendor_token = data.accessToken; |
|
|
|
this.router.navigate(['shop-details']); |
|
|
|
}, (err: any) => { |
|
|
|
this.errorMessage = err.error.message; |
|
|
|
setTimeout(() => { |
|
|
|
this.errorMessage = ''; |
|
|
|
}, 3000); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |