Advertisement
marciofullstack

login.js

Apr 13th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. import {Page, NavController, Modal, Alert} from 'ionic-angular';
  2. import {AuthService} from '../../services/auth-service';
  3. import {LoginForgetpasswordPage} from '../login-forgetpassword/login-forgetpassword';
  4. import {HomePage} from '../home/home';
  5.  
  6. @Page({
  7. templateUrl: 'build/pages/login/login.html',
  8. providers: [AuthService]
  9. })
  10. export class LoginPage {
  11.  
  12. static get parameters() {
  13. return [[NavController], [AuthService]];
  14. }
  15.  
  16. constructor(nav, AuthService) {
  17.  
  18. this.home = HomePage;
  19. this.forgetpassword = LoginForgetpasswordPage;
  20. this.login = {};
  21.  
  22. this.authservice = AuthService;
  23. this.nav = nav;
  24.  
  25. console.log('this.authservice', this.authservice);
  26. }
  27.  
  28.  
  29. onLogin() {
  30. if(this.login.username === undefined || this.login.password === undefined) {
  31.  
  32. let confirm = Alert.create({
  33. title: "Acesso negado!",
  34. body: "Preencha os campos obrigatórios.",
  35. buttons: [{ text: "OK"}]
  36. });
  37.  
  38. this.nav.present(confirm);
  39.  
  40. } else {
  41.  
  42. let objUser = {
  43. username: this.login.username,
  44. password: this.login.username
  45. };
  46.  
  47. if(this.authservice.login(objUser)) {
  48. console.log('passou');
  49. this.nav.setRoot(this.home);
  50. } else {
  51.  
  52. let confirm = Alert.create({
  53. title: "Acesso negado!",
  54. body: "Confira os dados de acesso e tente novamente.",
  55. buttons: [{ text: "OK"}]
  56. });
  57.  
  58. this.nav.present(confirm);
  59.  
  60. }
  61.  
  62. }
  63. }
  64.  
  65. onForgetPassword() {
  66.  
  67. let modal = Modal.create(LoginForgetpasswordPage);
  68.  
  69. modal.onDismiss((data) => {
  70. if(data) {
  71.  
  72. }
  73. });
  74.  
  75. // Toast.showShortBottom("Tarefa inserido com sucesso").subscribe((toast) => {
  76. // console.log('toast');
  77. // });
  78.  
  79. this.nav.present(modal);
  80.  
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement