@trudb/tru-common-lib 0.0.723 → 0.0.725

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.
@@ -3726,7 +3726,7 @@ class TruAuth {
3726
3726
  }));
3727
3727
  }
3728
3728
  setUser() {
3729
- this.auth.setUser(this.user);
3729
+ this.auth.createUser(this.user);
3730
3730
  }
3731
3731
  logout() {
3732
3732
  this.http
@@ -3735,11 +3735,16 @@ class TruAuth {
3735
3735
  });
3736
3736
  }
3737
3737
  userClaims() {
3738
- return this.http
3739
- .get(`${this.baseUrl}${TRU_AUTH_CONFIG.authUrl}/userClaims`)
3740
- .pipe(tap((userClaims) => {
3741
- this.user.create(userClaims);
3742
- }));
3738
+ if (this.appEnvironment.authType === 'session') {
3739
+ return this.http
3740
+ .get(`${this.baseUrl}${TRU_AUTH_CONFIG.authUrl}/userClaims`)
3741
+ .pipe(tap((userClaims) => {
3742
+ this.user.create(userClaims);
3743
+ }));
3744
+ }
3745
+ else {
3746
+ return this.auth.createUser(this.user);
3747
+ }
3743
3748
  }
3744
3749
  get isLoggedIn() {
3745
3750
  if (!this.loggedIn.value) {
@@ -5996,7 +6001,7 @@ class TruAuthJwtStrategy {
5996
6001
  isLoggedIn() {
5997
6002
  return !!this.getJwtToken();
5998
6003
  }
5999
- setUser(user) {
6004
+ createUser(user) {
6000
6005
  let jwtData = this.getDecodedJwtJsonData();
6001
6006
  console.log(jwtData);
6002
6007
  let userData = {
@@ -6007,7 +6012,7 @@ class TruAuthJwtStrategy {
6007
6012
  username: jwtData['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'],
6008
6013
  roles: jwtData['http://schemas.microsoft.com/ws/2008/06/identity/claims/role']
6009
6014
  };
6010
- user.create(userData);
6015
+ return of(user.create(userData));
6011
6016
  }
6012
6017
  getJwtToken() {
6013
6018
  try {
@@ -6018,7 +6023,7 @@ class TruAuthJwtStrategy {
6018
6023
  }
6019
6024
  }
6020
6025
  getDecodedJwtJsonData() {
6021
- let token = JSON.parse(localStorage.getItem(this.JWT_ACCESS_TOKEN));
6026
+ let token = this.getJwtToken();
6022
6027
  let payload = {};
6023
6028
  if (token && token !== "undefined") {
6024
6029
  const encodedPayload = token.split(".")[1];
@@ -6028,7 +6033,7 @@ class TruAuthJwtStrategy {
6028
6033
  return payload;
6029
6034
  }
6030
6035
  getToken() {
6031
- var token = JSON.parse(localStorage.getItem(this.JWT_ACCESS_TOKEN));
6036
+ var token = this.getJwtToken();
6032
6037
  if (token && token !== "undefined") {
6033
6038
  const encodedPayload = token.split(".")[1];
6034
6039
  const payloadStr = window.atob(encodedPayload);
@@ -6090,7 +6095,8 @@ class TruAuthSessionStrategy {
6090
6095
  doLogoutUser() {
6091
6096
  this.loggedUser = undefined;
6092
6097
  }
6093
- setUser(user) {
6098
+ createUser(user) {
6099
+ return of({});
6094
6100
  }
6095
6101
  isLoggedIn() {
6096
6102
  return false; //todo, implement this