This commit is contained in:
tiago.kayaya
2021-02-24 17:23:35 +01:00
parent 5b0e22e427
commit 6ba294d169
2 changed files with 29 additions and 30 deletions
+8 -27
View File
@@ -32,9 +32,8 @@ export class AuthService {
}
public ValidatedUser:User;
public ValidatedUser2:any;
async login(user: User): Promise<boolean> {
async login(user: User) {
this.alertCrontroller.presentAlert('1');
user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); //conversão em base64 das credenciais inseridas
@@ -48,34 +47,27 @@ export class AuthService {
let result: boolean | PromiseLike<boolean>;
let response: any;
this.alertCrontroller.presentAlert('2');
/* this.alertCrontroller.presentAlert('2');
this.http.get('http://jsonplaceholder.typicode.com/todos/1');
this.alertCrontroller.presentAlert('2.1');
this.http.get('https://jsonplaceholder.typicode.com/todos/1');
this.alertCrontroller.presentAlert('2.2');
var that = this;
var that = this; */
await this.http.get<boolean>(service, options).subscribe(res=>{
this.alertCrontroller.presentAlert('3.1');
//this.alertCrontroller.presentAlert('3.1');
result = res;
this.storage.set('login', res);
return result;
if (result)
{
this.alertCrontroller.presentAlert('4');
if (result){
//this.alertCrontroller.presentAlert('4');
this.ValidatedUser = user;
//this.storageService.store(AuthConnstants.USER, response);
}
});
this.storage.get('name').then((val) => {
console.log('Your age is', val);
});
this.alertCrontroller.presentAlert('3');
//this.alertCrontroller.presentAlert('3');
response = await this.http.post<any>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
console.log(response);
@@ -90,17 +82,7 @@ export class AuthService {
.then((val) => {
return val;
}); */
let t = this.get('name');
console.log(this.ValidatedUser2);
console.log(this.rs.map(responce=>responce.json()).toPromise());
return false;
}
async get(key: string): Promise<any> {
@@ -108,8 +90,7 @@ export class AuthService {
const result = await this.storage.get(key);
console.log('storageGET: ' + key + ': ' + result);
if (result != null) {
this.ValidatedUser2 = result;
return result;
return result;
}
return null;
} catch (reason) {