@trudb/tru-common-lib 0.0.711 → 0.0.715
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 +14 -1
- package/esm2020/lib/components/login/classes/tru-auth-logout-request.mjs +3 -0
- package/esm2020/lib/components/login/classes/tru-auth-session-strategy.mjs +2 -4
- package/esm2020/lib/components/login/services/tru-auth-interceptor.mjs +14 -7
- package/esm2020/lib/components/login/services/tru-auth.mjs +10 -16
- package/esm2020/lib/components/toolbar/user-profile/tru-toolbar-user-profile.mjs +2 -2
- package/fesm2015/trudb-tru-common-lib.mjs +49 -39
- package/fesm2015/trudb-tru-common-lib.mjs.map +1 -1
- package/fesm2020/trudb-tru-common-lib.mjs +49 -39
- package/fesm2020/trudb-tru-common-lib.mjs.map +1 -1
- package/lib/components/login/classes/tru-auth-config.d.ts +2 -1
- package/lib/components/login/classes/tru-auth-jwt-strategy.d.ts +2 -0
- package/lib/components/login/classes/tru-auth-logout-request.d.ts +3 -0
- package/lib/components/login/classes/tru-auth-session-strategy.d.ts +1 -1
- package/lib/components/login/services/tru-auth-interceptor.d.ts +5 -1
- package/lib/components/login/services/tru-auth.d.ts +2 -1
- package/package.json +1 -1
|
@@ -3720,26 +3720,20 @@ class TruAuth {
|
|
|
3720
3720
|
login(loginRequest) {
|
|
3721
3721
|
return this.http
|
|
3722
3722
|
.post(`${this.baseUrl}${TRU_AUTH_CONFIG.authUrl}/login`, loginRequest)
|
|
3723
|
-
.pipe(tap((
|
|
3724
|
-
this.auth.doLoginUser(
|
|
3723
|
+
.pipe(tap((data) => {
|
|
3724
|
+
this.auth.doLoginUser(data);
|
|
3725
3725
|
this.loggedIn.next(true);
|
|
3726
3726
|
}));
|
|
3727
3727
|
}
|
|
3728
3728
|
setUser() {
|
|
3729
|
-
|
|
3730
|
-
console.log(jwtData);
|
|
3731
|
-
let user = {
|
|
3732
|
-
activeUserRef: jwtData.UserRef,
|
|
3733
|
-
firstName: jwtData.FirstName,
|
|
3734
|
-
lastName: jwtData.LastName,
|
|
3735
|
-
email: jwtData.Email,
|
|
3736
|
-
username: jwtData['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'],
|
|
3737
|
-
roles: jwtData['http://schemas.microsoft.com/ws/2008/06/identity/claims/role']
|
|
3738
|
-
};
|
|
3739
|
-
this.user.create(user);
|
|
3729
|
+
this.auth.setUser(this.user);
|
|
3740
3730
|
}
|
|
3741
|
-
logout() {
|
|
3742
|
-
this.
|
|
3731
|
+
logout(logoutRequest) {
|
|
3732
|
+
return this.http
|
|
3733
|
+
.post(`${this.baseUrl}${TRU_AUTH_CONFIG.authUrl}/logout`, logoutRequest)
|
|
3734
|
+
.pipe(tap(() => {
|
|
3735
|
+
this.doLogoutAndRedirectToLogin();
|
|
3736
|
+
}));
|
|
3743
3737
|
}
|
|
3744
3738
|
get isLoggedIn() {
|
|
3745
3739
|
if (!this.loggedIn.value) {
|
|
@@ -3782,7 +3776,7 @@ class TruToolbarUserProfile {
|
|
|
3782
3776
|
this.uiNotification.changePassword();
|
|
3783
3777
|
};
|
|
3784
3778
|
this.onLogoutButtonClicked = () => {
|
|
3785
|
-
this.auth.
|
|
3779
|
+
this.auth.logout({ username: this.user.username });
|
|
3786
3780
|
};
|
|
3787
3781
|
this.initial = user?.firstName ? user?.firstName.slice(0, 1).toUpperCase() : user?.username?.slice(0, 1).toUpperCase();
|
|
3788
3782
|
this.name = user?.firstName && user?.lastName ? user?.firstName + ' ' + user?.lastName : user?.username;
|
|
@@ -5996,6 +5990,19 @@ class TruAuthJwtStrategy {
|
|
|
5996
5990
|
isLoggedIn() {
|
|
5997
5991
|
return !!this.getJwtToken();
|
|
5998
5992
|
}
|
|
5993
|
+
setUser(user) {
|
|
5994
|
+
let jwtData = this.getDecodedJwtJsonData();
|
|
5995
|
+
console.log(jwtData);
|
|
5996
|
+
let userData = {
|
|
5997
|
+
activeUserRef: jwtData.UserRef,
|
|
5998
|
+
firstName: jwtData.FirstName,
|
|
5999
|
+
lastName: jwtData.LastName,
|
|
6000
|
+
email: jwtData.Email,
|
|
6001
|
+
username: jwtData['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'],
|
|
6002
|
+
roles: jwtData['http://schemas.microsoft.com/ws/2008/06/identity/claims/role']
|
|
6003
|
+
};
|
|
6004
|
+
user.create(userData);
|
|
6005
|
+
}
|
|
5999
6006
|
getJwtToken() {
|
|
6000
6007
|
return JSON.parse(localStorage.getItem(this.JWT_ACCESS_TOKEN));
|
|
6001
6008
|
}
|
|
@@ -6027,14 +6034,33 @@ class TruAuthJwtStrategy {
|
|
|
6027
6034
|
}
|
|
6028
6035
|
}
|
|
6029
6036
|
|
|
6037
|
+
class TruAuthSessionStrategy {
|
|
6038
|
+
constructor(http) {
|
|
6039
|
+
this.http = http;
|
|
6040
|
+
}
|
|
6041
|
+
doLoginUser(user) {
|
|
6042
|
+
this.loggedUser = user;
|
|
6043
|
+
}
|
|
6044
|
+
doLogoutUser() {
|
|
6045
|
+
this.loggedUser = undefined;
|
|
6046
|
+
}
|
|
6047
|
+
setUser(user) {
|
|
6048
|
+
}
|
|
6049
|
+
isLoggedIn() {
|
|
6050
|
+
return false; //todo, implement this
|
|
6051
|
+
}
|
|
6052
|
+
}
|
|
6053
|
+
|
|
6030
6054
|
// import { ConfigService } from "../config.service";
|
|
6031
6055
|
class TruAuthInterceptor {
|
|
6032
|
-
constructor(auth, jwt) {
|
|
6056
|
+
constructor(auth, appEnvironment, jwt, session) {
|
|
6033
6057
|
this.auth = auth;
|
|
6058
|
+
this.appEnvironment = appEnvironment;
|
|
6034
6059
|
this.jwt = jwt;
|
|
6060
|
+
this.session = session;
|
|
6035
6061
|
}
|
|
6036
6062
|
intercept(request, next) {
|
|
6037
|
-
if (
|
|
6063
|
+
if (this.appEnvironment.authType === 'jwt') {
|
|
6038
6064
|
request = this.addToken(request, String(this.jwt.getToken()));
|
|
6039
6065
|
}
|
|
6040
6066
|
return next.handle(request).pipe(catchError((error) => {
|
|
@@ -6050,34 +6076,18 @@ class TruAuthInterceptor {
|
|
|
6050
6076
|
});
|
|
6051
6077
|
}
|
|
6052
6078
|
}
|
|
6053
|
-
TruAuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor, deps: [{ token: TruAuth }, { token: TRU_AUTH_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
6079
|
+
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 });
|
|
6054
6080
|
TruAuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor });
|
|
6055
6081
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuthInterceptor, decorators: [{
|
|
6056
6082
|
type: Injectable
|
|
6057
|
-
}], ctorParameters: function () { return [{ type: TruAuth }, { type: TruAuthJwtStrategy, decorators: [{
|
|
6083
|
+
}], ctorParameters: function () { return [{ type: TruAuth }, { type: TruAppEnvironment }, { type: TruAuthJwtStrategy, decorators: [{
|
|
6084
|
+
type: Inject,
|
|
6085
|
+
args: [TRU_AUTH_STRATEGY]
|
|
6086
|
+
}] }, { type: TruAuthSessionStrategy, decorators: [{
|
|
6058
6087
|
type: Inject,
|
|
6059
6088
|
args: [TRU_AUTH_STRATEGY]
|
|
6060
6089
|
}] }]; } });
|
|
6061
6090
|
|
|
6062
|
-
class TruAuthSessionStrategy {
|
|
6063
|
-
constructor(http) {
|
|
6064
|
-
this.http = http;
|
|
6065
|
-
}
|
|
6066
|
-
doLoginUser(user) {
|
|
6067
|
-
this.loggedUser = user;
|
|
6068
|
-
}
|
|
6069
|
-
doLogoutUser() {
|
|
6070
|
-
this.loggedUser = undefined;
|
|
6071
|
-
}
|
|
6072
|
-
getDecodedJwtJsonData() {
|
|
6073
|
-
return {};
|
|
6074
|
-
}
|
|
6075
|
-
;
|
|
6076
|
-
isLoggedIn() {
|
|
6077
|
-
return false; //todo, implement this
|
|
6078
|
-
}
|
|
6079
|
-
}
|
|
6080
|
-
|
|
6081
6091
|
const TruAuthStrategyProvider = {
|
|
6082
6092
|
provide: TRU_AUTH_STRATEGY,
|
|
6083
6093
|
deps: [HttpClient, TruAppEnvironment],
|