Implement new login done.

This commit is contained in:
tiago.kayaya
2021-01-19 10:44:55 +01:00
parent 08ec18a4d4
commit b90247b566
3 changed files with 28 additions and 1 deletions
+22 -1
View File
@@ -13,12 +13,17 @@ import { AuthConnstants } from '../config/auth-constants';
})
export class AuthService {
userData$ = new BehaviorSubject<any>('');
userId$ = new BehaviorSubject<any>('');
headers: HttpHeaders;
opts:any;
constructor(
private http: HttpClient,
private httpService: HttpService,
private storageService:StorageService,
private router:Router
) { }
) {
this.headers = new HttpHeaders();
}
public ValidatedUser:User;
@@ -26,11 +31,21 @@ export class AuthService {
user.BasicAuthKey = 'Basic ' + btoa(user.domainName + '\\' + user.username + ':' + user.password); //conversão em base64 das credenciais inseridas
const options = { headers: {'Authorization': user.BasicAuthKey }};
this.headers = this.headers.set('Authorization',user.BasicAuthKey);
this.opts = {
headers: this.headers,
}
const service = environment.apiURL + "userauthentication/GetValidateAuth";
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=>{
this.storageService.store(AuthConnstants.USER, res);
});
if (result)
{
@@ -56,6 +71,12 @@ export class AuthService {
this.userData$.next(res);
});
}
//Get user Id | global object
getUserId(){
this.storageService.get(AuthConnstants.USER).then(res=>{
this.userId$.next(res);
});
}
getProfile(){
this.storageService.get(AuthConnstants.PROFILE).then(res=>{