@trudb/tru-common-lib 0.0.717 → 0.0.719

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.
@@ -6041,37 +6041,21 @@ class TruAuthJwtStrategy {
6041
6041
  }
6042
6042
  }
6043
6043
 
6044
- class TruAuthSessionStrategy {
6045
- constructor(http) {
6046
- this.http = http;
6047
- }
6048
- doLoginUser(user) {
6049
- this.loggedUser = user;
6050
- }
6051
- doLogoutUser() {
6052
- this.loggedUser = undefined;
6053
- }
6054
- setUser(user) {
6055
- }
6056
- isLoggedIn() {
6057
- return false; //todo, implement this
6058
- }
6059
- }
6060
-
6061
- // import { ConfigService } from "../config.service";
6062
6044
  class TruAuthInterceptor {
6063
- constructor(auth, appEnvironment, jwt, session) {
6045
+ constructor(auth, appEnvironment, jwt) {
6064
6046
  this.auth = auth;
6065
6047
  this.appEnvironment = appEnvironment;
6066
6048
  this.jwt = jwt;
6067
- this.session = session;
6068
6049
  }
6069
6050
  intercept(request, next) {
6070
- if (this.appEnvironment.authType === 'jwt') {
6051
+ if (this.appEnvironment.authType === 'jwt')
6071
6052
  request = this.addToken(request, String(this.jwt.getToken()));
6072
- }
6053
+ if (this.appEnvironment.authType === 'session')
6054
+ request = request.clone({
6055
+ withCredentials: true
6056
+ });
6073
6057
  return next.handle(request).pipe(catchError((error) => {
6074
- if (error.status === 401) {
6058
+ if (error.status === 401 || error.status === 404) {
6075
6059
  this.auth.doLogoutAndRedirectToLogin();
6076
6060
  }
6077
6061
  return throwError(error);
@@ -6083,18 +6067,32 @@ class TruAuthInterceptor {
6083
6067
  });
6084
6068
  }
6085
6069
  }
6086
- TruAuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor, deps: [{ token: TruAuth }, { token: TruAppEnvironment }, { token: TRU_AUTH_STRATEGY }, { token: TRU_AUTH_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
6070
+ TruAuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor, deps: [{ token: TruAuth }, { token: TruAppEnvironment }, { token: TRU_AUTH_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
6087
6071
  TruAuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor });
6088
6072
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor, decorators: [{
6089
6073
  type: Injectable
6090
6074
  }], ctorParameters: function () { return [{ type: TruAuth }, { type: TruAppEnvironment }, { type: TruAuthJwtStrategy, decorators: [{
6091
6075
  type: Inject,
6092
6076
  args: [TRU_AUTH_STRATEGY]
6093
- }] }, { type: TruAuthSessionStrategy, decorators: [{
6094
- type: Inject,
6095
- args: [TRU_AUTH_STRATEGY]
6096
6077
  }] }]; } });
6097
6078
 
6079
+ class TruAuthSessionStrategy {
6080
+ constructor(http) {
6081
+ this.http = http;
6082
+ }
6083
+ doLoginUser(user) {
6084
+ this.loggedUser = user;
6085
+ }
6086
+ doLogoutUser() {
6087
+ this.loggedUser = undefined;
6088
+ }
6089
+ setUser(user) {
6090
+ }
6091
+ isLoggedIn() {
6092
+ return false; //todo, implement this
6093
+ }
6094
+ }
6095
+
6098
6096
  const TruAuthStrategyProvider = {
6099
6097
  provide: TRU_AUTH_STRATEGY,
6100
6098
  deps: [HttpClient, TruAppEnvironment],