This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onAutenticar(): void { | |
//Se estiver conectado na rede | |
if (this.network.type != 'none') { | |
ESTÁ EXECUTANDO AQUI ->>>>> | |
this.getUsuario(this.LoginForm.value.login, this.LoginForm.value.senha) | |
.then(() => { | |
// aqui vai seu codigo | |
ESTÁ EXECUTANDO AQUI AO MESMO TEMPO | |
->>>>> console.log(this.usuario.login); | |
E NESSE CASO O CONSOLE.LOG VAI SER NULO, PQ MEU OBJETO AINDA NÃO FOI PREENCHIDO NO MÉTODO CHAMADO ACIMA, NÃO ERA PRA SER EXECUTADO NA SEQUENCIA? | |
if ((this.usuario.login == this.LoginForm.value.login) && (this.usuario.senha == this.LoginForm.value.senha) && (this.usuario.perfil == this.perfil[0])) { | |
this.navCtrl.push(UsuariosPage); | |
} | |
else if ((this.usuario.login == this.LoginForm.value.login) && (this.usuario.senha == this.LoginForm.value.senha) && (this.usuario.perfil == this.perfil[1])) { | |
this.navCtrl.setRoot(EficienciaPage, { "usuario": this.LoginForm.value.login }); | |
} | |
else { | |
this.showAlertErroLogin(); | |
} | |
}); | |
} else { | |
this.showAlertDesconectado(); | |
} | |
this.LoginForm.reset(); | |
} | |
private getUsuario(login: string, senha: string) { | |
return new Promise((resolve, reject) => { | |
this.usuarioProdiver.selectUsuario(login, senha) | |
.then((rs: any) => { | |
this.usuario.id = rs.id; | |
this.usuario.login = rs.login; | |
this.usuario.senha = rs.senha; | |
this.usuario.perfil = rs.perfil; | |
resolve(); | |
}) | |
.catch((e) => reject(e)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment