Guest User

Untitled

a guest
Jan 4th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { AuthService } from '../services/auth.service';
  3. import { ChatService } from '../services/chat.service';
  4.  
  5. @Component({
  6. selector: 'app-login-form',
  7. templateUrl: './login-form.component.html',
  8. styleUrls: ['./login-form.component.css']
  9. })
  10. export class LoginFormComponent {
  11.  
  12. email: string;
  13. password: string;
  14. userId: any;
  15. users: any;
  16. invalidEmail: string;
  17. errors: any;
  18.  
  19. constructor(private authService: AuthService,
  20. private chatService: ChatService) { }
  21.  
  22. login() {
  23. this.chatService.getUserList().valueChanges().subscribe(
  24. user => {
  25. this.users = user;
  26. for (let i = 0; i < this.users.length; i++) {
  27. if (this.users[i]['email'] === this.email) {
  28. this.authService.login(this.email, this.password);
  29. break;
  30. } else if ( i === this.users.length - 1) {
  31. this.invalidEmail = 'Email not found';
  32. }
  33. }
  34. }
  35. );
  36. }
  37. }
Add Comment
Please, Sign In to add comment