@trudb/tru-common-lib 0.0.681 → 0.0.682

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -282,25 +282,26 @@ class TruUser {
282
282
  this._lastName = null;
283
283
  this._email = null;
284
284
  this._roles = null;
285
- this._userSet = false;
286
285
  this.hasRoles = (roles) => {
287
286
  if (this._roles === null)
288
287
  return true;
289
288
  return _.intersection(roles, this._roles).length > 0;
290
289
  };
291
290
  this.create = (user) => {
292
- if (!this._userSet) {
293
- this._ref = user.activeUserRef;
294
- this._username = user.username;
295
- this._firstName = user.firstName;
296
- this._lastName = user.lastName;
297
- this._email = user.email;
298
- this._roles = user.roles;
299
- this._userSet = true;
300
- }
301
- else {
302
- throw new Error('User has already been set for this session.');
303
- }
291
+ this._ref = user.activeUserRef;
292
+ this._username = user.username;
293
+ this._firstName = user.firstName;
294
+ this._lastName = user.lastName;
295
+ this._email = user.email;
296
+ this._roles = user.roles;
297
+ };
298
+ this.destroy = () => {
299
+ this._ref = -1;
300
+ this._username = null;
301
+ this._firstName = null;
302
+ this._lastName = null;
303
+ this._email = null;
304
+ this._roles = null;
304
305
  };
305
306
  }
306
307
  get activeUserRef() {
@@ -3653,10 +3654,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
3653
3654
  }] });
3654
3655
 
3655
3656
  class TruAuth {
3656
- constructor(router, http, cache, appEnvironment, auth) {
3657
+ constructor(router, http, cache, user, appEnvironment, auth) {
3657
3658
  this.router = router;
3658
3659
  this.http = http;
3659
3660
  this.cache = cache;
3661
+ this.user = user;
3660
3662
  this.appEnvironment = appEnvironment;
3661
3663
  this.auth = auth;
3662
3664
  this.loggedIn = new BehaviorSubject(false);
@@ -3692,18 +3694,19 @@ class TruAuth {
3692
3694
  this.router.navigate([""]);
3693
3695
  }
3694
3696
  doLogoutUser() {
3697
+ this.user.destroy();
3695
3698
  this.cache.pruneAll();
3696
3699
  this.auth.doLogoutUser();
3697
3700
  }
3698
3701
  }
3699
- TruAuth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuth, deps: [{ token: i1$6.Router }, { token: i1$3.HttpClient }, { token: TruAuthCache }, { token: TruAppEnvironment }, { token: TRU_AUTH_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
3702
+ TruAuth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuth, deps: [{ token: i1$6.Router }, { token: i1$3.HttpClient }, { token: TruAuthCache }, { token: TruUser }, { token: TruAppEnvironment }, { token: TRU_AUTH_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
3700
3703
  TruAuth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuth, providedIn: "root" });
3701
3704
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuth, decorators: [{
3702
3705
  type: Injectable,
3703
3706
  args: [{
3704
3707
  providedIn: "root",
3705
3708
  }]
3706
- }], ctorParameters: function () { return [{ type: i1$6.Router }, { type: i1$3.HttpClient }, { type: TruAuthCache }, { type: TruAppEnvironment }, { type: undefined, decorators: [{
3709
+ }], ctorParameters: function () { return [{ type: i1$6.Router }, { type: i1$3.HttpClient }, { type: TruAuthCache }, { type: TruUser }, { type: TruAppEnvironment }, { type: undefined, decorators: [{
3707
3710
  type: Inject,
3708
3711
  args: [TRU_AUTH_STRATEGY]
3709
3712
  }] }]; } });