Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Page, NavController, Modal, Alert} from 'ionic-angular';
- import {AuthService} from '../../services/auth-service';
- import {LoginForgetpasswordPage} from '../login-forgetpassword/login-forgetpassword';
- import {HomePage} from '../home/home';
- @Page({
- templateUrl: 'build/pages/login/login.html',
- providers: [AuthService]
- })
- export class LoginPage {
- static get parameters() {
- return [[NavController], [AuthService]];
- }
- constructor(nav, AuthService) {
- this.home = HomePage;
- this.forgetpassword = LoginForgetpasswordPage;
- this.login = {};
- this.authservice = AuthService;
- this.nav = nav;
- console.log('this.authservice', this.authservice);
- }
- onLogin() {
- if(this.login.username === undefined || this.login.password === undefined) {
- let confirm = Alert.create({
- title: "Acesso negado!",
- body: "Preencha os campos obrigatórios.",
- buttons: [{ text: "OK"}]
- });
- this.nav.present(confirm);
- } else {
- let objUser = {
- username: this.login.username,
- password: this.login.username
- };
- if(this.authservice.login(objUser)) {
- console.log('passou');
- this.nav.setRoot(this.home);
- } else {
- let confirm = Alert.create({
- title: "Acesso negado!",
- body: "Confira os dados de acesso e tente novamente.",
- buttons: [{ text: "OK"}]
- });
- this.nav.present(confirm);
- }
- }
- }
- onForgetPassword() {
- let modal = Modal.create(LoginForgetpasswordPage);
- modal.onDismiss((data) => {
- if(data) {
- }
- });
- // Toast.showShortBottom("Tarefa inserido com sucesso").subscribe((toast) => {
- // console.log('toast');
- // });
- this.nav.present(modal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement