diff --git a/config.xml b/config.xml index 7043c0399..0d54a1497 100644 --- a/config.xml +++ b/config.xml @@ -1,8 +1,8 @@ Gabinete Digital - An awesome Ionic/Cordova app. - Ionic Framework Team + Aplicação do Gabinete Digital do Presidente da República de Angola + Equilibrium Team diff --git a/resources/android/xml/network_security_config.xml b/resources/android/xml/network_security_config.xml index de61259aa..9f500fa7e 100644 --- a/resources/android/xml/network_security_config.xml +++ b/resources/android/xml/network_security_config.xml @@ -2,5 +2,7 @@ localhost + gabinetedigital.local + diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index cde1de028..c72618466 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -30,13 +30,6 @@ export class LoginPage implements OnInit { } /* Function to validade the login inputs */ validateInput(){ - this.userattempt = { - username: this.username, - password: this.password, - domainName: "", - BasicAuthKey: "" - } - return ( this.username.trim().length > 0 && this.password.trim().length > 0 @@ -54,22 +47,33 @@ export class LoginPage implements OnInit { await alert.present(); } - async Login(){ - //Go to our home in home/feed. - if(this.validateInput()){ - if (await this.authService.login(this.userattempt)) - { - this.router.navigate(['/home/events']); + async Login(){ + try { + //Go to our home in home/feed. + if(this.validateInput()){ + this.userattempt = { + username: this.username, + password: this.password, + domainName: environment.domain, + BasicAuthKey: "" + } + + if (await this.authService.login(this.userattempt)) + { + this.router.navigate(['/home/events']); + } + else + { + /* this.toastService.presentToast('Não foi possível fazer login"'); */ + this.presentAlert('O nome de utilizador e palavra-passe estão incorretas ou verifique a sua conexão com a internet e volte a tentar.'); + } } - else - { - /* this.toastService.presentToast('Não foi possível fazer login"'); */ - this.presentAlert('O nome de utilizador e palavra-passe estão incorretas ou verifique a sua conexão com a internet e volte a tentar.'); - } - } - else{ - /* this.toastService.presentToast('Preencha todos campos'); */ - this.presentAlert('Por favor, insira o seu nome de utilizador e palavra-passe.'); + else{ + /* this.toastService.presentToast('Preencha todos campos'); */ + this.presentAlert('Por favor, insira o seu nome de utilizador e palavra-passe.'); + } + } catch (error) { + this.presentAlert('Ocorreu um erro ao fazer login. Contacte o administrador de sistema.'); } } } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 5b3a0605f..e8990d1a4 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -23,7 +23,6 @@ export class AuthService { public ValidatedUser:User; async login(user: User): Promise { - user.domainName = environment.domain; user.BasicAuthKey = 'Basic ' + btoa(user.domainName + '\\' + user.username + ':' + user.password); //conversão em base64 das credenciais inseridas const options = { headers: {'Authorization': user.BasicAuthKey }}; @@ -31,11 +30,7 @@ export class AuthService { let result: boolean | PromiseLike; - try { - result = await this.http.get(service, options).toPromise(); - } catch(e) { - result = false; - } + result = await this.http.get(service, options).toPromise(); if (result) {