@coolon/angular-ui-powerups 14.26.0 → 14.28.0
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/place/components/abstract-place-navigation.component.mjs +7 -5
- package/esm2020/lib/place/components/place-outlet/place-outlet.component.mjs +2 -2
- package/esm2020/lib/place/guards/place.guard.mjs +12 -4
- package/esm2020/lib/place/place-router.mjs +10 -6
- package/fesm2015/coolon-angular-ui-powerups.mjs +27 -13
- package/fesm2015/coolon-angular-ui-powerups.mjs.map +1 -1
- package/fesm2020/coolon-angular-ui-powerups.mjs +27 -13
- package/fesm2020/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/place/place-router.d.ts +16 -2
- package/package.json +1 -1
|
@@ -7491,7 +7491,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
7491
7491
|
* An observable model containing the authoriser function. This allows places to react to changes
|
|
7492
7492
|
* in permissions when any underlying auth logic changes, e.g. a role being removed from a user.
|
|
7493
7493
|
*/
|
|
7494
|
-
this._accessGuard = this.registerDisposable(new DelegatingValueModel().withDefault(new PlaceAccessGuard.NoAuth()));
|
|
7494
|
+
this._accessGuard$ = this.registerDisposable(new DelegatingValueModel().withDefault(new PlaceAccessGuard.NoAuth()));
|
|
7495
7495
|
if (window["Cypress"]) {
|
|
7496
7496
|
window["aup.PlaceRouter"] = this;
|
|
7497
7497
|
}
|
|
@@ -7551,8 +7551,8 @@ class PlaceRouter extends GarbageCollector {
|
|
|
7551
7551
|
// the back button was clicked.
|
|
7552
7552
|
angularLocation.onUrlChange(url => this.onUrlChanged(url));
|
|
7553
7553
|
}
|
|
7554
|
-
get accessGuard() {
|
|
7555
|
-
return this._accessGuard
|
|
7554
|
+
get accessGuard$() {
|
|
7555
|
+
return this._accessGuard$.readonly;
|
|
7556
7556
|
}
|
|
7557
7557
|
// @Trace()
|
|
7558
7558
|
configureAuth(accessGrant, redirections) {
|
|
@@ -7565,12 +7565,15 @@ class PlaceRouter extends GarbageCollector {
|
|
|
7565
7565
|
toLeft: (rightValue) => rightValue
|
|
7566
7566
|
});
|
|
7567
7567
|
binding.writeLeft();
|
|
7568
|
-
this._accessGuard
|
|
7568
|
+
this._accessGuard$.setDelegate(hackyMutableModel);
|
|
7569
7569
|
this.redirections = redirections;
|
|
7570
7570
|
}
|
|
7571
7571
|
getAuthenticationFailureRedirect(activatedRoute, state) {
|
|
7572
7572
|
return this.redirections.onAuthenticationFailure(activatedRoute, state);
|
|
7573
7573
|
}
|
|
7574
|
+
getAuthorisationFailureRedirectOptions(component) {
|
|
7575
|
+
return this.redirections.onAuthorisationFailure(component);
|
|
7576
|
+
}
|
|
7574
7577
|
get navigationSession() {
|
|
7575
7578
|
return this.navigationSession$.value;
|
|
7576
7579
|
}
|
|
@@ -7756,7 +7759,8 @@ class PlaceRouter extends GarbageCollector {
|
|
|
7756
7759
|
* the app directly and we don't get to ask.
|
|
7757
7760
|
*/
|
|
7758
7761
|
// @Trace()
|
|
7759
|
-
syncInteractionContextIdsWithRouter(onSyncComplete = () => {
|
|
7762
|
+
syncInteractionContextIdsWithRouter(onSyncComplete = () => {
|
|
7763
|
+
}) {
|
|
7760
7764
|
if (this.navigationSession) {
|
|
7761
7765
|
// console.log(`Navigation active -> ${this.navigationSession.toString()}, sync delayed until finished.`);
|
|
7762
7766
|
const session = this.navigationSession;
|
|
@@ -9682,7 +9686,7 @@ class PlaceOutletComponent extends DisposableComponent {
|
|
|
9682
9686
|
chain(this._activePlaceModel)
|
|
9683
9687
|
.postponeWhile(this.navigationInProgress)
|
|
9684
9688
|
.subscribe(place => this.placeChanged.emit(place));
|
|
9685
|
-
this.authorised = chain(placeRouter.accessGuard).map(guard => guard.isAuthorised(this._activePlaceDefinition.value), {
|
|
9689
|
+
this.authorised = chain(placeRouter.accessGuard$).map(guard => guard.isAuthorised(this._activePlaceDefinition.value), {
|
|
9686
9690
|
dependsOn: this._activePlaceDefinition,
|
|
9687
9691
|
postponeWhile: chain(this._activePlaceDefinition).isNil()
|
|
9688
9692
|
}).otherwise(true); // if we don't have a place def yet we need to show the outlet so we get one injected.
|
|
@@ -9884,10 +9888,12 @@ class AbstractPlaceNavigationComponent extends DisposableComponent {
|
|
|
9884
9888
|
this.placeDefinitions = chain(this.placesModel)
|
|
9885
9889
|
.map(c => PlaceComponent.getDefinition(c))
|
|
9886
9890
|
.select(d => {
|
|
9887
|
-
const guard = placeRouter.accessGuard
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
+
const guard = placeRouter.accessGuard$.value;
|
|
9892
|
+
return guard.isAuthorised(d);
|
|
9893
|
+
}, {
|
|
9894
|
+
postponeWhile: placeRouter.navigationInProgress$,
|
|
9895
|
+
dependsOn: [placeRouter.accessGuard$, placeRouter.state$]
|
|
9896
|
+
});
|
|
9891
9897
|
this.commandFactory = Command.createFactory((placeDefinition) => {
|
|
9892
9898
|
this.placeOutlet.navigate(new Visit(placeDefinition));
|
|
9893
9899
|
});
|
|
@@ -10416,17 +10422,25 @@ class PlaceGuard {
|
|
|
10416
10422
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10417
10423
|
if (PlaceComponent.isPlaceComponentConstructor(activatedRoute.component)) {
|
|
10418
10424
|
const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);
|
|
10419
|
-
const accessGuard = this.placeRouter.accessGuard
|
|
10425
|
+
const accessGuard = this.placeRouter.accessGuard$.value;
|
|
10420
10426
|
if (placeDefinition.authenticate) {
|
|
10421
10427
|
const authenticated = yield accessGuard.isAuthenticated();
|
|
10422
|
-
if (!authenticated
|
|
10428
|
+
if (!authenticated) {
|
|
10423
10429
|
const redirectLocation = this.placeRouter.getAuthenticationFailureRedirect(activatedRoute, state);
|
|
10424
10430
|
const nextPlaceDef = this.getPlaceDefinition(redirectLocation);
|
|
10425
10431
|
if (nextPlaceDef.authenticate) {
|
|
10426
|
-
lang.illegalState(`
|
|
10432
|
+
lang.illegalState(`onAuthenticationFailure hook returned place ${nextPlaceDef.component.name} that requires authentication.`);
|
|
10427
10433
|
}
|
|
10428
10434
|
return this.createUrlTree(redirectLocation);
|
|
10429
10435
|
}
|
|
10436
|
+
if (!accessGuard.isAuthorised(placeDefinition) && !placeDefinition.redirectToFirstChild) {
|
|
10437
|
+
const redirectOptions = this.placeRouter.getAuthorisationFailureRedirectOptions(activatedRoute.component);
|
|
10438
|
+
const nextRedirect = redirectOptions.find(it => accessGuard.isAuthorised(this.getPlaceDefinition(it)));
|
|
10439
|
+
if (!nextRedirect) {
|
|
10440
|
+
lang.illegalState(`onAuthorisationFailure hook didn't return any authorised locations: ${redirectOptions.map(it => this.getPlaceDefinition(it).component.name).join(', ')}`);
|
|
10441
|
+
}
|
|
10442
|
+
return this.createUrlTree(nextRedirect);
|
|
10443
|
+
}
|
|
10430
10444
|
}
|
|
10431
10445
|
const result = yield this.cleanInteractionState(activatedRoute, state, () => __awaiter(this, void 0, void 0, function* () {
|
|
10432
10446
|
const navigationSession = this.placeRouter.navigationSession;
|