changed login and api

This commit is contained in:
tiago.kayaya
2021-01-25 11:02:56 +01:00
parent e577bbb695
commit f8db0b681b
2 changed files with 16 additions and 13 deletions
+14 -12
View File
@@ -27,8 +27,9 @@ export class AuthService {
public ValidatedUser:User;
async login(user: User): Promise<boolean> {
user.BasicAuthKey = 'Basic ' + btoa(user.domainName + '\\' + user.username + ':' + user.password); //conversão em base64 das credenciais inseridas
async login(user: User): Promise<any> {
/* 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<boolean>;
/* let result: boolean | PromiseLike<boolean>; */
let response: any;
result = await this.http.get<boolean>(service, options).toPromise();
this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).subscribe(res=>{
/* result = await this.http.get<boolean>(service, options).toPromise(); */
response = await this.http.post<any>(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