This commit is contained in:
tiago.kayaya
2021-01-15 15:25:13 +01:00
parent 092557b21e
commit 7e18af8233
4 changed files with 10 additions and 33 deletions
@@ -13,5 +13,8 @@
"SplashScreen": "screen",
"SplashScreenDelay": "3000"
}
},
"android": {
"allowMixedContent": true
}
}
+3
View File
@@ -13,5 +13,8 @@
"SplashScreen": "screen",
"SplashScreenDelay": "3000"
}
},
"android": {
"allowMixedContent": true
}
}
+3 -4
View File
@@ -67,7 +67,7 @@ export class LoginPage implements OnInit {
async Login(){
try {
/* try { */
//Go to our home in home/feed.
//this.router.navigate(['/home/events']);
if(this.validateInput()){
@@ -79,7 +79,6 @@ export class LoginPage implements OnInit {
}
if (await this.authService.login(this.userattempt)){
this.loginRocketChat();
console.log('Log Gabinete Digital OK');
this.router.navigate(['/home/events']);this.presentAlert('1');
}
else
@@ -92,9 +91,9 @@ export class LoginPage implements OnInit {
//this.toastService.presentToast('Preencha todos campos');
this.presentAlert('Por favor, insira o seu nome de utilizador e palavra-passe.');
}
} catch (error) {
/* } catch (error) {
error
this.presentAlert('Ocorreu um erro ao fazer login. Contacte o administrador de sistema. '+ error);
}
} */
}
}
+1 -29
View File
@@ -7,7 +7,6 @@ import { environment } from 'src/environments/environment';
import { HttpService } from './http.service';
import { BehaviorSubject, Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
import { AlertController } from '@ionic/angular';
@Injectable({
providedIn: 'root'
@@ -18,51 +17,24 @@ export class AuthService {
private http: HttpClient,
private httpService: HttpService,
private storageService:StorageService,
public alertController: AlertController,
private router:Router
) { }
public ValidatedUser:User;
async presentAlert(message:string) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Mensagem do sistema',
message: message,
buttons: ['OK']
});
await alert.present();
}
async login(user: User): Promise<boolean> {
user.BasicAuthKey = 'Basic ' + btoa(user.domainName + '\\' + user.username + ':' + user.password); //conversão em base64 das credenciais inseridas
const options = { headers: {'Authorization': user.BasicAuthKey }};
const service = environment.apiURL + "userauthentication/GetValidateAuth";
let result: boolean | PromiseLike<boolean>;
this.presentAlert(service);
try {
result = await this.http.get<boolean>(service, options).toPromise();
} catch (error) {
this.presentAlert('Erro '+error);
}
result = await this.http.get<boolean>(service, options).toPromise();
if (result)
{
this.presentAlert('7');
this.ValidatedUser = user;
this.presentAlert('8');
}
return result;