@trudb/tru-common-lib 0.0.718 → 0.0.720

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.
@@ -3728,9 +3728,9 @@ class TruAuth {
3728
3728
  setUser() {
3729
3729
  this.auth.setUser(this.user);
3730
3730
  }
3731
- logout(logoutRequest) {
3731
+ logout() {
3732
3732
  return this.http
3733
- .post(`${this.baseUrl}${TRU_AUTH_CONFIG.authUrl}/logout`, logoutRequest)
3733
+ .post(`${this.baseUrl}${TRU_AUTH_CONFIG.authUrl}/logout`, null)
3734
3734
  .pipe(tap(() => {
3735
3735
  this.doLogoutAndRedirectToLogin();
3736
3736
  }));
@@ -3783,7 +3783,7 @@ class TruToolbarUserProfile {
3783
3783
  this.uiNotification.changePassword();
3784
3784
  };
3785
3785
  this.onLogoutButtonClicked = () => {
3786
- this.auth.logout({ username: this.user.username });
3786
+ this.auth.logout();
3787
3787
  };
3788
3788
  this.initial = user?.firstName ? user?.firstName.slice(0, 1).toUpperCase() : user?.username?.slice(0, 1).toUpperCase();
3789
3789
  this.name = user?.firstName && user?.lastName ? user?.firstName + ' ' + user?.lastName : user?.username;
@@ -6041,40 +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
- }
6073
- request = request.clone({
6074
- withCredentials: true
6075
- });
6053
+ if (this.appEnvironment.authType === 'session')
6054
+ request = request.clone({
6055
+ withCredentials: true
6056
+ });
6076
6057
  return next.handle(request).pipe(catchError((error) => {
6077
- if (error.status === 401) {
6058
+ if (error.status === 401 || error.status === 404) {
6078
6059
  this.auth.doLogoutAndRedirectToLogin();
6079
6060
  }
6080
6061
  return throwError(error);
@@ -6086,18 +6067,32 @@ class TruAuthInterceptor {
6086
6067
  });
6087
6068
  }
6088
6069
  }
6089
- 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 });
6090
6071
  TruAuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor });
6091
6072
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor, decorators: [{
6092
6073
  type: Injectable
6093
6074
  }], ctorParameters: function () { return [{ type: TruAuth }, { type: TruAppEnvironment }, { type: TruAuthJwtStrategy, decorators: [{
6094
6075
  type: Inject,
6095
6076
  args: [TRU_AUTH_STRATEGY]
6096
- }] }, { type: TruAuthSessionStrategy, decorators: [{
6097
- type: Inject,
6098
- args: [TRU_AUTH_STRATEGY]
6099
6077
  }] }]; } });
6100
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
+
6101
6096
  const TruAuthStrategyProvider = {
6102
6097
  provide: TRU_AUTH_STRATEGY,
6103
6098
  deps: [HttpClient, TruAppEnvironment],