From f8db0b681b0dc5375349d3e15a539eca2123de69 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Mon, 25 Jan 2021 11:02:56 +0100 Subject: [PATCH] changed login and api --- src/app/services/auth.service.ts | 26 ++++++++++++++------------ src/environments/environment.ts | 3 ++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 9529f4bb1..b9cbf8a5a 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -27,8 +27,9 @@ export class AuthService { public ValidatedUser:User; - async login(user: User): Promise { - user.BasicAuthKey = 'Basic ' + btoa(user.domainName + '\\' + user.username + ':' + user.password); //conversão em base64 das credenciais inseridas + async login(user: User): Promise { + /* user.BasicAuthKey = 'Basic ' + btoa(user.domainName + '\\' + user.username + ':' + user.password); //conversão em base64 das credenciais inseridas */ + user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); //conversão em base64 das credenciais inseridas const options = { headers: {'Authorization': user.BasicAuthKey }}; this.headers = this.headers.set('Authorization',user.BasicAuthKey); @@ -37,27 +38,28 @@ export class AuthService { } const service = environment.apiURL + "userauthentication/GetValidateAuth"; - let result: boolean | PromiseLike; + /* let result: boolean | PromiseLike; */ let response: any; - result = await this.http.get(service, options).toPromise(); - this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).subscribe(res=>{ + /* result = await this.http.get(service, options).toPromise(); */ + response = await this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise(); + /* 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); + }); */ - - if (result) + if (response) { this.ValidatedUser = user; - + this.storageService.store(AuthConnstants.USER, response); } - return result; + return response; } logout(){ this.ValidatedUser = null; - } //Login to rocketChat server diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 8a7f53f62..f7b2ad41e 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -5,7 +5,8 @@ export const environment = { production: false, apiURL: 'https://equilibrium.dyndns.info/GabineteDigital.Services/V4/api/', - apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', + /* apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', */ + apiChatUrl: 'https://www.tabularium.pt/api/v1/', domain: 'gabinetedigital.local', defaultuser: 'paulo.pinto', defaultuserpwd: 'tabteste@006'