This commit is contained in:
tiago.kayaya
2021-06-09 14:00:14 +01:00
parent 2283b52df0
commit 2e98333c88
2 changed files with 26 additions and 17 deletions
+22 -16
View File
@@ -51,29 +51,35 @@ export class AuthService {
}
const service = environment.apiURL + "userauthentication/GetValidateAuth";
let result: boolean | PromiseLike<boolean>;
let result: boolean | PromiseLike<boolean> = false;
let response: any;
result = await this.http.get<boolean>(service, options).toPromise();
response = await this.http.post<User>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
try {
result = await this.http.get<boolean>(service, options).toPromise();
response = await this.http.post<User>(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(){