Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export class DataService {
- public errorMessage: string;
- public showAlert: boolean = false;
- public checkCredentials(url:string, username:string, password:string):Observable<any>{
- return this.http.get<Object>(url).pipe(tap (users => {
- const checkCookie = this.cookie.get('login');
- if (users.find(u => u.user === username)) {
- this.usuario = users.find(u => u.user === username);
- if (username === this.usuario.user && password === this.usuario.pass && !checkCookie) {
- this.cookie.set('login', this.usuario.mail);
- this.router.navigate(['configuration']);
- } else {
- this.errorMesssage = 'Se han introducido unas credenciales incorrectas';
- this.showAlert = true;
- }
- } else {
- this.errorMessage = 'El usuario introducido no se ha encontrado';
- this.showAlert = true;
- }
- return this.errorMesssage;
- }));
- this.errorMesssage = 'Se han introducido unas credenciales incorrectas';
- La propiedad "errorMesssage" no existe en el tipo "DataService". ¿Quería decir "errorMessage"?
- const url = 'assets/users.json';
- this.service.checkCredentials(url,this.username,this.password).subscribe();
Add Comment
Please, Sign In to add comment