Guest User

Untitled

a guest
Jun 25th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. export class DataService {
  2.  
  3. public errorMessage: string;
  4. public showAlert: boolean = false;
  5.  
  6. public checkCredentials(url:string, username:string, password:string):Observable<any>{
  7.  
  8. return this.http.get<Object>(url).pipe(tap (users => {
  9.  
  10. const checkCookie = this.cookie.get('login');
  11.  
  12. if (users.find(u => u.user === username)) {
  13. this.usuario = users.find(u => u.user === username);
  14. if (username === this.usuario.user && password === this.usuario.pass && !checkCookie) {
  15. this.cookie.set('login', this.usuario.mail);
  16. this.router.navigate(['configuration']);
  17. } else {
  18. this.errorMesssage = 'Se han introducido unas credenciales incorrectas';
  19. this.showAlert = true;
  20. }
  21. } else {
  22. this.errorMessage = 'El usuario introducido no se ha encontrado';
  23. this.showAlert = true;
  24. }
  25.  
  26. return this.errorMesssage;
  27.  
  28. }));
  29.  
  30. this.errorMesssage = 'Se han introducido unas credenciales incorrectas';
  31.  
  32. La propiedad "errorMesssage" no existe en el tipo "DataService". ¿Quería decir "errorMessage"?
  33.  
  34. const url = 'assets/users.json';
  35. this.service.checkCredentials(url,this.username,this.password).subscribe();
Add Comment
Please, Sign In to add comment