Advertisement
Guest User

Untitled

a guest
Nov 21st, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. import {MyPortsPage} from '../my-ports/my-ports'
  2. import {Component} from "@angular/core";
  3. import {NavController} from 'ionic-angular';
  4. import {UsersService} from '../../providers/users-service/users-service.ts';
  5. @Component({
  6. templateUrl: 'build/pages/home/home.html',
  7. providers: [UsersService]
  8. })
  9. export class HomePage {
  10. email : string
  11. senha : string
  12. users:any
  13. public existUser: number
  14. constructor(private navController: NavController, public usersService: UsersService) {
  15. //this.autentication();
  16. }
  17. autentication () {
  18. this.existUser = 0
  19. this.usersService.autentication()
  20. .then(data => {
  21. this.users = data;
  22. for(var d in data) {
  23. //alert(data[d].email);
  24. if (data[d].email == this.email) {
  25. if (data[d].pass == this.senha) {
  26. localStorage.setItem('usId', data[d].id);
  27. localStorage.setItem('usLogin', data[d].login);
  28. this.existUser++;
  29. //alert('ok');
  30. break;
  31. }
  32. }
  33. }
  34. if (this.existUser == 0) {alert('Não foi possivel autenticar - Usuário não existe');}
  35.  
  36. });
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement