Ele mostra alerta = 1, mas vai para a página de dashboard, mas deveria ficar na tela de login
signIn(): void { if (this.signInForm.invalid) { return; } this.signInForm.disable(); this.showAlert = false; this.maisUmaEmpresa = false; this.loginService.login(this.signInForm.value).subscribe( () => { this.http .get(environment.START + API + "usuario-empresa/usuario-logado/") .subscribe(async (ret: any) => { this.stateStorageService.storeEmpresas(ret); if (ret.length > 1) { alert(1); this.signInForm.enable(); this.maisUmaEmpresa = true; this.empresas = this.stateStorageService.getEmpresas(); return; } else { alert(2); await this.finalizandoLogin(ret[0].id); } }); }, (error: any) => { this.errorService.error(error); this.signInForm.enable(); } ); }
private async finalizandoLogin(idEmpresa: string): Promise<any> { alert(5); try { alert(3); const usuario = await this.usuarioLogadoService .buscarDadosUsuarioLogado() .then() .catch((error) => { this.errorService.error(error); this.signInForm.enable(); }); const empresa = await this.empresaService .buscarPorId(idEmpresa) .then() .catch((error) => { this.errorService.error(error); this.signInForm.enable(); }); this.stateStorageService.storeUsuarioLogado({ usuario, empresa }); this.stateStorageService.clearEmpresas(); this.router.navigate(["/dashboard"]); } catch (error) { this.errorService.error(error); } }
Local funciona e em homologação não
