mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
changed login and api
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user