@trudb/tru-common-lib 0.0.705 → 0.0.708
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.
- package/esm2020/lib/components/login/classes/tru-auth-config.mjs +1 -1
- package/esm2020/lib/components/login/classes/tru-auth-jwt-strategy.mjs +11 -1
- package/esm2020/lib/components/login/classes/tru-auth-session-strategy.mjs +4 -13
- package/esm2020/lib/components/login/services/tru-auth.mjs +18 -12
- package/fesm2015/trudb-tru-common-lib.mjs +30 -22
- package/fesm2015/trudb-tru-common-lib.mjs.map +1 -1
- package/fesm2020/trudb-tru-common-lib.mjs +30 -22
- package/fesm2020/trudb-tru-common-lib.mjs.map +1 -1
- package/lib/components/login/classes/tru-auth-config.d.ts +1 -0
- package/lib/components/login/classes/tru-auth-jwt-strategy.d.ts +1 -0
- package/lib/components/login/classes/tru-auth-session-strategy.d.ts +1 -2
- package/lib/components/login/services/tru-auth.d.ts +1 -2
- package/package.json +1 -1
|
@@ -70,7 +70,7 @@ import * as signalR from '@microsoft/signalr';
|
|
|
70
70
|
import moment$1 from 'moment';
|
|
71
71
|
import * as i8 from 'ag-grid-angular';
|
|
72
72
|
import { AgGridModule } from 'ag-grid-angular';
|
|
73
|
-
import { tap,
|
|
73
|
+
import { tap, catchError } from 'rxjs/operators';
|
|
74
74
|
import * as i1$6 from '@angular/router';
|
|
75
75
|
import { RouterModule } from '@angular/router';
|
|
76
76
|
import * as i1$7 from '@angular/platform-browser';
|
|
@@ -3678,9 +3678,6 @@ const TRU_AUTH_CONFIG = {
|
|
|
3678
3678
|
};
|
|
3679
3679
|
const TRU_AUTH_STRATEGY = new InjectionToken("AuthStrategy");
|
|
3680
3680
|
|
|
3681
|
-
class TruAuthUserRequest {
|
|
3682
|
-
}
|
|
3683
|
-
|
|
3684
3681
|
class TruAuthCache {
|
|
3685
3682
|
constructor() {
|
|
3686
3683
|
this.prunables = [];
|
|
@@ -3711,21 +3708,28 @@ class TruAuth {
|
|
|
3711
3708
|
this.auth = auth;
|
|
3712
3709
|
this.loggedIn = new BehaviorSubject(false);
|
|
3713
3710
|
this.baseUrl = '';
|
|
3714
|
-
this.createUserRequest = (username) => {
|
|
3715
|
-
let truUser = new TruAuthUserRequest();
|
|
3716
|
-
truUser.username = username;
|
|
3717
|
-
return truUser;
|
|
3718
|
-
};
|
|
3719
3711
|
this.baseUrl = this.appEnvironment.appUri;
|
|
3720
3712
|
}
|
|
3721
3713
|
login(loginRequest) {
|
|
3722
3714
|
return this.http
|
|
3723
3715
|
.post(`${this.baseUrl}${TRU_AUTH_CONFIG.authUrl}/login`, loginRequest)
|
|
3724
|
-
.pipe(tap((tokenData) =>
|
|
3725
|
-
this.auth.doLoginUser(
|
|
3726
|
-
this.user.create(userData);
|
|
3716
|
+
.pipe(tap((tokenData) => {
|
|
3717
|
+
this.auth.doLoginUser(tokenData);
|
|
3727
3718
|
this.loggedIn.next(true);
|
|
3728
|
-
}))
|
|
3719
|
+
}));
|
|
3720
|
+
}
|
|
3721
|
+
setUser() {
|
|
3722
|
+
let jwtData = this.auth.getDecodedJwtJsonData();
|
|
3723
|
+
console.log(jwtData);
|
|
3724
|
+
let user = {
|
|
3725
|
+
activeUserRef: jwtData.UserRef,
|
|
3726
|
+
firstName: jwtData.FirstName,
|
|
3727
|
+
lastName: jwtData.LastName,
|
|
3728
|
+
email: jwtData.Email,
|
|
3729
|
+
username: jwtData['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'],
|
|
3730
|
+
roles: jwtData['http://schemas.microsoft.com/ws/2008/06/identity/claims/role']
|
|
3731
|
+
};
|
|
3732
|
+
this.user.create(user);
|
|
3729
3733
|
}
|
|
3730
3734
|
logout() {
|
|
3731
3735
|
this.doLogoutUser();
|
|
@@ -5988,6 +5992,16 @@ class TruAuthJwtStrategy {
|
|
|
5988
5992
|
getJwtToken() {
|
|
5989
5993
|
return JSON.parse(localStorage.getItem(this.JWT_ACCESS_TOKEN));
|
|
5990
5994
|
}
|
|
5995
|
+
getDecodedJwtJsonData() {
|
|
5996
|
+
let token = JSON.parse(localStorage.getItem(this.JWT_ACCESS_TOKEN));
|
|
5997
|
+
let payload = {};
|
|
5998
|
+
if (token && token !== "undefined") {
|
|
5999
|
+
const encodedPayload = token.split(".")[1];
|
|
6000
|
+
const payloadStr = window.atob(encodedPayload);
|
|
6001
|
+
payload = JSON.parse(payloadStr);
|
|
6002
|
+
}
|
|
6003
|
+
return payload;
|
|
6004
|
+
}
|
|
5991
6005
|
getToken() {
|
|
5992
6006
|
var token = JSON.parse(localStorage.getItem(this.JWT_ACCESS_TOKEN));
|
|
5993
6007
|
if (token && token !== "undefined") {
|
|
@@ -6048,16 +6062,10 @@ class TruAuthSessionStrategy {
|
|
|
6048
6062
|
doLogoutUser() {
|
|
6049
6063
|
this.loggedUser = undefined;
|
|
6050
6064
|
}
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
return of(this.loggedUser);
|
|
6054
|
-
}
|
|
6055
|
-
else {
|
|
6056
|
-
return this.http
|
|
6057
|
-
.get(`${TRU_AUTH_CONFIG.authUrl}/user`)
|
|
6058
|
-
.pipe(tap((user) => (this.loggedUser = user)));
|
|
6059
|
-
}
|
|
6065
|
+
getDecodedJwtJsonData() {
|
|
6066
|
+
return {};
|
|
6060
6067
|
}
|
|
6068
|
+
;
|
|
6061
6069
|
isLoggedIn() {
|
|
6062
6070
|
return false; //todo, implement this
|
|
6063
6071
|
}
|