diff --git a/config.xml b/config.xml index 6f65c248a..64e69955e 100644 --- a/config.xml +++ b/config.xml @@ -134,7 +134,7 @@ 0 - 8.0.0.00-20210201-110557 + 8.0.0.00-20210214-154410 diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 948d36328..6ff36b53d 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -/* import { StorageService } from './storage.service'; */ +import { StorageService } from './storage.service'; import { Router } from '@angular/router'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { User } from '../models/user.model'; @@ -7,9 +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 { AlertService } from './alert.service'; -import { map } from 'rxjs/operators'; -import { Storage } from '@ionic/storage'; @Injectable({ providedIn: 'root' @@ -19,22 +16,18 @@ export class AuthService { userId$ = new BehaviorSubject(''); headers: HttpHeaders; opts:any; - rs:any; constructor( private http: HttpClient, private httpService: HttpService, -/* private storageService:StorageService, */ - private router:Router, - private alertCrontroller: AlertService, - private storage: Storage, + private storageService:StorageService, + private router:Router ) { this.headers = new HttpHeaders(); } public ValidatedUser:User; - async login(user: User) { - this.alertCrontroller.presentAlert('1'); + async login(user: User): Promise { user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); //conversão em base64 das credenciais inseridas const options = { headers: {'Authorization': user.BasicAuthKey }}; @@ -47,58 +40,23 @@ export class AuthService { let result: boolean | PromiseLike; let response: any; - /* 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; */ - - await this.http.get(service, options).subscribe(res=>{ - //this.alertCrontroller.presentAlert('3.1'); - result = res; - this.storage.set('login', res); - if (result){ - //this.alertCrontroller.presentAlert('4'); - this.ValidatedUser = user; - //this.storageService.store(AuthConnstants.USER, response); - } - - }); - - - //this.alertCrontroller.presentAlert('3'); + result = await this.http.get(service, options).toPromise(); response = await this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise(); - console.log(response); - /* this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).subscribe(res=>{ this.storageService.store(AuthConnstants.USER, res); this.ValidatedUser = user; response = user; console.log(user); }); */ - - /* this.rs = this.storage.get('name').toPromise() - .then((val) => { - return val; - }); */ - + + if (result) + { + this.ValidatedUser = user; + //this.storageService.store(AuthConnstants.USER, response); + } + return result; } - async get(key: string): Promise { - try { - const result = await this.storage.get(key); - console.log('storageGET: ' + key + ': ' + result); - if (result != null) { - return result; - } - return null; - } catch (reason) { - console.log(reason); - return null; - } - } - logout(){ this.ValidatedUser = null; }