mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Implement new login done.
This commit is contained in:
@@ -3,4 +3,5 @@ export class AuthConnstants{
|
||||
/* My reference key */
|
||||
public static readonly AUTH = 'userDataKey';
|
||||
public static readonly PROFILE = 'profile';
|
||||
public static readonly USER = 'userId';
|
||||
}
|
||||
@@ -99,6 +99,11 @@ export class EventsPage implements OnInit {
|
||||
|
||||
} */
|
||||
|
||||
this.storageService.get(AuthConnstants.USER).then(res=>{
|
||||
console.log(res);
|
||||
|
||||
});
|
||||
|
||||
this.showGreeting();
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
|
||||
@@ -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=>{
|
||||
|
||||
Reference in New Issue
Block a user