Vendor app Client: Maiora
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

53 rader
1.4 KiB

  1. import { Component, OnInit } from '@angular/core';
  2. import { Router } from '@angular/router';
  3. import { AuthService } from '../services/auth.service';
  4. @Component({
  5. selector: 'app-login',
  6. templateUrl: './login.component.html',
  7. styleUrls: ['./login.component.scss']
  8. })
  9. export class LoginComponent implements OnInit {
  10. credentials = {
  11. username: 'suresh',
  12. password: '123456789',
  13. login_type: "OUTLET"
  14. };
  15. // ramsesrh
  16. login_types = ['VENDOR', 'OUTLET'];
  17. errorMessage: string = '';
  18. constructor(
  19. public router: Router,
  20. private authService: AuthService
  21. ) { }
  22. ngOnInit() {
  23. }
  24. requestAuthentication() {
  25. this.authService.authenticateUser(this.credentials).then((data: any) => {
  26. localStorage.current_login_type = this.credentials.login_type;
  27. localStorage.token = data.access_Token;
  28. localStorage.user_info = JSON.stringify(data['User Info']);
  29. if (this.credentials.login_type === 'VENDOR') {
  30. localStorage.vendor_info = JSON.stringify(data['Info Info']);
  31. } else {
  32. localStorage.outlet_info = JSON.stringify(data['Outlet Info']);
  33. }
  34. this.router.navigate(['shop-details']);
  35. }, (err: any) => {
  36. this.errorMessage = 'Please check your credentials';
  37. setTimeout(() => {
  38. this.errorMessage = '';
  39. }, 3000);
  40. });
  41. }
  42. }