From 2e98333c8861be7fb2bff570a7122c40a9fdc1c3 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Wed, 9 Jun 2021 14:00:14 +0100 Subject: [PATCH] save --- src/app/pages/login/login.page.ts | 5 +++- src/app/services/auth.service.ts | 38 ++++++++++++++++++------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 1165d7a67..02cbb4c4d 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -118,7 +118,10 @@ export class LoginPage implements OnInit { domainName: environment.domain, BasicAuthKey: "" } - if (await this.authService.login(this.userattempt)) { + let attempt = await this.authService.login(this.userattempt); + console.log(JSON.stringify(attempt)); + + if (attempt) { //this.loginRocketChat(); this.authService.loginChat(this.userattempt); //this.getToken(); diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 1585007f6..922b85145 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -51,29 +51,35 @@ export class AuthService { } const service = environment.apiURL + "userauthentication/GetValidateAuth"; - let result: boolean | PromiseLike; + let result: boolean | PromiseLike = false; let response: any; - result = await this.http.get(service, options).toPromise(); - response = await this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise(); + try { + result = await this.http.get(service, options).toPromise(); + response = await this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise(); - console.log(response) + console.log(response); - if (result) { + if (result) { + if( response.RoleID == 100000014) { + response.Profile = 'PR' + } else if(response.RoleID == 100000011) { + response.Profile = 'MDGPR' + } + response.BasicAuthKey = user.BasicAuthKey + this.ValidatedUser = response; - if( response.RoleID == 100000014) { - response.Profile = 'PR' - } else if(response.RoleID == 100000011) { - response.Profile = 'MDGPR' + localStorage.setItem('user', JSON.stringify(response)); + + this.storageService.store(AuthConnstants.USER, response); + + return result; } - response.BasicAuthKey = user.BasicAuthKey - this.ValidatedUser = response; - - localStorage.setItem('user', JSON.stringify(response)); - - this.storageService.store(AuthConnstants.USER, response); + + } catch (error) { + return result; } - return result; + } logout(){