@flusys/ng-auth 9.1.2 → 9.2.1
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/fesm2022/flusys-ng-auth-administration-page.component-DmN4KqiR.mjs.map +1 -1
- package/fesm2022/{flusys-ng-auth-social-callback-page.component-gTD7_LJY.mjs → flusys-ng-auth-social-callback-page.component-uE6vIUtK.mjs} +3 -1
- package/fesm2022/{flusys-ng-auth-social-callback-page.component-gTD7_LJY.mjs.map → flusys-ng-auth-social-callback-page.component-uE6vIUtK.mjs.map} +1 -1
- package/fesm2022/{flusys-ng-auth-social-config-page.component-DpGmcb9n.mjs → flusys-ng-auth-social-config-page.component-DQvkiR7M.mjs} +1 -3
- package/fesm2022/flusys-ng-auth-social-config-page.component-DQvkiR7M.mjs.map +1 -0
- package/fesm2022/{flusys-ng-auth-user-form.component-CM9UYc0q.mjs → flusys-ng-auth-user-form.component-C5ncAjU9.mjs} +4 -4
- package/fesm2022/{flusys-ng-auth-user-form.component-CM9UYc0q.mjs.map → flusys-ng-auth-user-form.component-C5ncAjU9.mjs.map} +1 -1
- package/fesm2022/{flusys-ng-auth-user-list.component-Bew7gz-H.mjs → flusys-ng-auth-user-list.component-BNYmRTlN.mjs} +2 -2
- package/fesm2022/{flusys-ng-auth-user-list.component-Bew7gz-H.mjs.map → flusys-ng-auth-user-list.component-BNYmRTlN.mjs.map} +1 -1
- package/fesm2022/flusys-ng-auth.mjs +30 -17
- package/fesm2022/flusys-ng-auth.mjs.map +1 -1
- package/package.json +5 -5
- package/types/flusys-ng-auth.d.ts +3 -1
- package/fesm2022/flusys-ng-auth-social-config-page.component-DpGmcb9n.mjs.map +0 -1
|
@@ -2,7 +2,7 @@ import { HttpClient } from "@angular/common/http";
|
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
import { Component, DOCUMENT, DestroyRef, InjectionToken, PLATFORM_ID, Service, computed, effect, inject, input, output, resource, signal } from "@angular/core";
|
|
4
4
|
import { APP_CONFIG, getServiceUrl, isCompanyFeatureEnabled } from "@flusys/ng-core";
|
|
5
|
-
import { BehaviorSubject, catchError, filter, finalize, firstValueFrom, from, map, of, shareReplay, switchMap, take, tap, throwError, timeout } from "rxjs";
|
|
5
|
+
import { BehaviorSubject, Subject, catchError, filter, finalize, firstValueFrom, from, map, of, race, shareReplay, switchMap, take, tap, throwError, timeout } from "rxjs";
|
|
6
6
|
import { Router } from "@angular/router";
|
|
7
7
|
import { AUTH_STATE_PROVIDER, ApiResourceService, BRANCH_PERMISSIONS, COMPANY_API_PROVIDER, COMPANY_PERMISSIONS, CookieService, HasPermissionDirective, PermissionValidatorService, PlatformService, SHARED_MESSAGES, SOCIAL_AUTH_CONFIG_PERMISSIONS, TranslatePipe, TranslateService, USER_PERMISSIONS, USER_PERMISSION_PROVIDER, USER_PROVIDER, flattenBranchTree, getBranchPath, permissionGuard, resolveTranslationModule } from "@flusys/ng-shared";
|
|
8
8
|
import { catchError as catchError$1, map as map$1, tap as tap$1 } from "rxjs/operators";
|
|
@@ -517,6 +517,8 @@ var TokenRefreshStateService = class TokenRefreshStateService {
|
|
|
517
517
|
isRefreshing = this._isRefreshing.asReadonly();
|
|
518
518
|
_refreshTokenSubject = new BehaviorSubject(null);
|
|
519
519
|
refreshTokenSubject$ = this._refreshTokenSubject.asObservable();
|
|
520
|
+
_refreshFailed = new Subject();
|
|
521
|
+
refreshFailed$ = this._refreshFailed.asObservable();
|
|
520
522
|
startRefresh() {
|
|
521
523
|
this._isRefreshing.set(true);
|
|
522
524
|
this._refreshTokenSubject.next(null);
|
|
@@ -525,8 +527,9 @@ var TokenRefreshStateService = class TokenRefreshStateService {
|
|
|
525
527
|
this._isRefreshing.set(false);
|
|
526
528
|
this._refreshTokenSubject.next(newToken);
|
|
527
529
|
}
|
|
528
|
-
failRefresh() {
|
|
530
|
+
failRefresh(error) {
|
|
529
531
|
this._isRefreshing.set(false);
|
|
532
|
+
this._refreshFailed.next(error);
|
|
530
533
|
}
|
|
531
534
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
532
535
|
minVersion: "12.0.0",
|
|
@@ -802,7 +805,7 @@ const guestGuard = (route) => {
|
|
|
802
805
|
if (authState.isAuthenticated()) {
|
|
803
806
|
if (appConfig.enableCompanyFeature && !authState.company()) return true;
|
|
804
807
|
const returnUrl = route.queryParams["returnUrl"];
|
|
805
|
-
return
|
|
808
|
+
return isValidReturnUrl(returnUrl) ? router.parseUrl(returnUrl) : router.createUrlTree(["/"]);
|
|
806
809
|
}
|
|
807
810
|
return true;
|
|
808
811
|
};
|
|
@@ -877,16 +880,19 @@ function tokenRefreshInterceptor(req, next) {
|
|
|
877
880
|
}));
|
|
878
881
|
}
|
|
879
882
|
function handleTokenRefresh(req, next, authState, authApi, messageService, isBrowser, refreshState, t) {
|
|
880
|
-
if (refreshState.isRefreshing()) return refreshState.refreshTokenSubject$.pipe(filter((token) => token !== null), take(1), switchMap((token) => next(req.clone({ setHeaders: { Authorization: `Bearer ${token}` } }))));
|
|
883
|
+
if (refreshState.isRefreshing()) return race(refreshState.refreshTokenSubject$.pipe(filter((token) => token !== null), take(1)), refreshState.refreshFailed$.pipe(take(1), switchMap((error) => throwError(() => error)))).pipe(switchMap((token) => next(req.clone({ setHeaders: { Authorization: `Bearer ${token}` } }))));
|
|
881
884
|
refreshState.startRefresh();
|
|
882
|
-
return authApi.refresh().pipe(
|
|
883
|
-
const newToken = response.data
|
|
885
|
+
return authApi.refresh().pipe(map((response) => {
|
|
886
|
+
const newToken = response.data?.accessToken;
|
|
887
|
+
if (!newToken) throw new Error("auth.session.expired");
|
|
888
|
+
return newToken;
|
|
889
|
+
}), catchError((refreshError) => {
|
|
890
|
+
refreshState.failRefresh(refreshError);
|
|
891
|
+
return handleRefreshFailure(authState, messageService, isBrowser, refreshError, t);
|
|
892
|
+
}), switchMap((newToken) => {
|
|
884
893
|
authState.setAccessToken(newToken);
|
|
885
894
|
refreshState.completeRefresh(newToken);
|
|
886
895
|
return next(req.clone({ setHeaders: { Authorization: `Bearer ${newToken}` } }));
|
|
887
|
-
}), catchError((refreshError) => {
|
|
888
|
-
refreshState.failRefresh();
|
|
889
|
-
return handleRefreshFailure(authState, messageService, isBrowser, refreshError, t);
|
|
890
896
|
}));
|
|
891
897
|
}
|
|
892
898
|
function handleRefreshFailure(authState, messageService, isBrowser, error, t) {
|
|
@@ -895,7 +901,7 @@ function handleRefreshFailure(authState, messageService, isBrowser, error, t) {
|
|
|
895
901
|
messageService.add({
|
|
896
902
|
severity: "error",
|
|
897
903
|
summary: t("auth.session.expired.title"),
|
|
898
|
-
detail: t(detailKey)
|
|
904
|
+
detail: t(detailKey || "auth.session.expired")
|
|
899
905
|
});
|
|
900
906
|
}
|
|
901
907
|
authState.resetState();
|
|
@@ -1258,7 +1264,7 @@ const AUTH_ROUTES = [{
|
|
|
1258
1264
|
},
|
|
1259
1265
|
{
|
|
1260
1266
|
path: "social/callback",
|
|
1261
|
-
loadComponent: () => import("./flusys-ng-auth-social-callback-page.component-
|
|
1267
|
+
loadComponent: () => import("./flusys-ng-auth-social-callback-page.component-uE6vIUtK.mjs").then((m) => m.SocialCallbackPageComponent)
|
|
1262
1268
|
},
|
|
1263
1269
|
{
|
|
1264
1270
|
path: "verify-email",
|
|
@@ -1290,15 +1296,15 @@ const ADMINISTRATION_ROUTES = [{
|
|
|
1290
1296
|
children: [
|
|
1291
1297
|
{
|
|
1292
1298
|
path: "",
|
|
1293
|
-
loadComponent: () => import("./flusys-ng-auth-user-list.component-
|
|
1299
|
+
loadComponent: () => import("./flusys-ng-auth-user-list.component-BNYmRTlN.mjs").then((m) => m.UserListComponent)
|
|
1294
1300
|
},
|
|
1295
1301
|
{
|
|
1296
1302
|
path: "new",
|
|
1297
|
-
loadComponent: () => import("./flusys-ng-auth-user-form.component-
|
|
1303
|
+
loadComponent: () => import("./flusys-ng-auth-user-form.component-C5ncAjU9.mjs").then((m) => m.UserFormComponent)
|
|
1298
1304
|
},
|
|
1299
1305
|
{
|
|
1300
1306
|
path: ":id",
|
|
1301
|
-
loadComponent: () => import("./flusys-ng-auth-user-form.component-
|
|
1307
|
+
loadComponent: () => import("./flusys-ng-auth-user-form.component-C5ncAjU9.mjs").then((m) => m.UserFormComponent)
|
|
1302
1308
|
}
|
|
1303
1309
|
]
|
|
1304
1310
|
},
|
|
@@ -1341,7 +1347,7 @@ const ADMINISTRATION_ROUTES = [{
|
|
|
1341
1347
|
{
|
|
1342
1348
|
path: "social-config",
|
|
1343
1349
|
canActivate: [permissionGuard(SOCIAL_AUTH_CONFIG_PERMISSIONS.READ)],
|
|
1344
|
-
loadComponent: () => import("./flusys-ng-auth-social-config-page.component-
|
|
1350
|
+
loadComponent: () => import("./flusys-ng-auth-social-config-page.component-DQvkiR7M.mjs").then((m) => m.SocialConfigPageComponent)
|
|
1345
1351
|
},
|
|
1346
1352
|
{
|
|
1347
1353
|
path: "",
|
|
@@ -1420,8 +1426,12 @@ var AuthLayoutApiAdapter = class AuthLayoutApiAdapter {
|
|
|
1420
1426
|
authState = inject(AuthStateService);
|
|
1421
1427
|
router = inject(Router);
|
|
1422
1428
|
logOut() {
|
|
1423
|
-
return this.authApi.logout().pipe(tap$1(
|
|
1424
|
-
this.authState.resetState()
|
|
1429
|
+
return this.authApi.logout().pipe(tap$1({
|
|
1430
|
+
next: () => this.authState.resetState(),
|
|
1431
|
+
error: () => {
|
|
1432
|
+
this.authState.resetState();
|
|
1433
|
+
this.authState.navigateToLogin();
|
|
1434
|
+
}
|
|
1425
1435
|
}));
|
|
1426
1436
|
}
|
|
1427
1437
|
navigateLogin(withUrl) {
|
|
@@ -1753,6 +1763,7 @@ var BranchPermittedUsersDialogComponent = class BranchPermittedUsersDialogCompon
|
|
|
1753
1763
|
this.isLoading.set(true);
|
|
1754
1764
|
try {
|
|
1755
1765
|
const response = await firstValueFrom(this.permissionApi.getBranchUsers(branch.id));
|
|
1766
|
+
if (this.branch()?.id !== branch.id) return;
|
|
1756
1767
|
this.users.set(response.data ?? []);
|
|
1757
1768
|
} catch {} finally {
|
|
1758
1769
|
this.isLoading.set(false);
|
|
@@ -2129,6 +2140,7 @@ var CompanyPermittedUsersDialogComponent = class CompanyPermittedUsersDialogComp
|
|
|
2129
2140
|
this.isLoading.set(true);
|
|
2130
2141
|
try {
|
|
2131
2142
|
const response = await firstValueFrom(this.permissionApi.getCompanyUsers(company.id));
|
|
2143
|
+
if (this.company()?.id !== company.id) return;
|
|
2132
2144
|
this.users.set(response.data ?? []);
|
|
2133
2145
|
} catch {} finally {
|
|
2134
2146
|
this.isLoading.set(false);
|
|
@@ -3363,6 +3375,7 @@ var UserCompanyPermissionDialogComponent = class UserCompanyPermissionDialogComp
|
|
|
3363
3375
|
sort: {}
|
|
3364
3376
|
});
|
|
3365
3377
|
const assignedResponse = await firstValueFrom(this.permissionApi.getUserCompanies(currentUser.id));
|
|
3378
|
+
if (this.user()?.id !== currentUser.id) return;
|
|
3366
3379
|
this.assignedCompanyIds.clear();
|
|
3367
3380
|
if (assignedResponse.data) assignedResponse.data.forEach((permission) => {
|
|
3368
3381
|
this.assignedCompanyIds.add(permission.companyId);
|