@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
|
@@ -7128,7 +7128,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
7128
7128
|
* An observable model containing the authoriser function. This allows places to react to changes
|
|
7129
7129
|
* in permissions when any underlying auth logic changes, e.g. a role being removed from a user.
|
|
7130
7130
|
*/
|
|
7131
|
-
this._accessGuard = this.registerDisposable(new DelegatingValueModel().withDefault(new PlaceAccessGuard.NoAuth()));
|
|
7131
|
+
this._accessGuard$ = this.registerDisposable(new DelegatingValueModel().withDefault(new PlaceAccessGuard.NoAuth()));
|
|
7132
7132
|
if (window["Cypress"]) {
|
|
7133
7133
|
window["aup.PlaceRouter"] = this;
|
|
7134
7134
|
}
|
|
@@ -7188,8 +7188,8 @@ class PlaceRouter extends GarbageCollector {
|
|
|
7188
7188
|
// the back button was clicked.
|
|
7189
7189
|
angularLocation.onUrlChange(url => this.onUrlChanged(url));
|
|
7190
7190
|
}
|
|
7191
|
-
get accessGuard() {
|
|
7192
|
-
return this._accessGuard
|
|
7191
|
+
get accessGuard$() {
|
|
7192
|
+
return this._accessGuard$.readonly;
|
|
7193
7193
|
}
|
|
7194
7194
|
// @Trace()
|
|
7195
7195
|
configureAuth(accessGrant, redirections) {
|
|
@@ -7202,12 +7202,15 @@ class PlaceRouter extends GarbageCollector {
|
|
|
7202
7202
|
toLeft: (rightValue) => rightValue
|
|
7203
7203
|
});
|
|
7204
7204
|
binding.writeLeft();
|
|
7205
|
-
this._accessGuard
|
|
7205
|
+
this._accessGuard$.setDelegate(hackyMutableModel);
|
|
7206
7206
|
this.redirections = redirections;
|
|
7207
7207
|
}
|
|
7208
7208
|
getAuthenticationFailureRedirect(activatedRoute, state) {
|
|
7209
7209
|
return this.redirections.onAuthenticationFailure(activatedRoute, state);
|
|
7210
7210
|
}
|
|
7211
|
+
getAuthorisationFailureRedirectOptions(component) {
|
|
7212
|
+
return this.redirections.onAuthorisationFailure(component);
|
|
7213
|
+
}
|
|
7211
7214
|
get navigationSession() {
|
|
7212
7215
|
return this.navigationSession$.value;
|
|
7213
7216
|
}
|
|
@@ -7387,7 +7390,8 @@ class PlaceRouter extends GarbageCollector {
|
|
|
7387
7390
|
* the app directly and we don't get to ask.
|
|
7388
7391
|
*/
|
|
7389
7392
|
// @Trace()
|
|
7390
|
-
syncInteractionContextIdsWithRouter(onSyncComplete = () => {
|
|
7393
|
+
syncInteractionContextIdsWithRouter(onSyncComplete = () => {
|
|
7394
|
+
}) {
|
|
7391
7395
|
if (this.navigationSession) {
|
|
7392
7396
|
// console.log(`Navigation active -> ${this.navigationSession.toString()}, sync delayed until finished.`);
|
|
7393
7397
|
const session = this.navigationSession;
|
|
@@ -9573,7 +9577,7 @@ class PlaceOutletComponent extends DisposableComponent {
|
|
|
9573
9577
|
chain(this._activePlaceModel)
|
|
9574
9578
|
.postponeWhile(this.navigationInProgress)
|
|
9575
9579
|
.subscribe(place => this.placeChanged.emit(place));
|
|
9576
|
-
this.authorised = chain(placeRouter.accessGuard).map(guard => guard.isAuthorised(this._activePlaceDefinition.value), {
|
|
9580
|
+
this.authorised = chain(placeRouter.accessGuard$).map(guard => guard.isAuthorised(this._activePlaceDefinition.value), {
|
|
9577
9581
|
dependsOn: this._activePlaceDefinition,
|
|
9578
9582
|
postponeWhile: chain(this._activePlaceDefinition).isNil()
|
|
9579
9583
|
}).otherwise(true); // if we don't have a place def yet we need to show the outlet so we get one injected.
|
|
@@ -9771,10 +9775,12 @@ class AbstractPlaceNavigationComponent extends DisposableComponent {
|
|
|
9771
9775
|
this.placeDefinitions = chain(this.placesModel)
|
|
9772
9776
|
.map(c => PlaceComponent.getDefinition(c))
|
|
9773
9777
|
.select(d => {
|
|
9774
|
-
const guard = placeRouter.accessGuard
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
+
const guard = placeRouter.accessGuard$.value;
|
|
9779
|
+
return guard.isAuthorised(d);
|
|
9780
|
+
}, {
|
|
9781
|
+
postponeWhile: placeRouter.navigationInProgress$,
|
|
9782
|
+
dependsOn: [placeRouter.accessGuard$, placeRouter.state$]
|
|
9783
|
+
});
|
|
9778
9784
|
this.commandFactory = Command.createFactory((placeDefinition) => {
|
|
9779
9785
|
this.placeOutlet.navigate(new Visit(placeDefinition));
|
|
9780
9786
|
});
|
|
@@ -10304,17 +10310,25 @@ class PlaceGuard {
|
|
|
10304
10310
|
async canActivate(activatedRoute, state) {
|
|
10305
10311
|
if (PlaceComponent.isPlaceComponentConstructor(activatedRoute.component)) {
|
|
10306
10312
|
const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);
|
|
10307
|
-
const accessGuard = this.placeRouter.accessGuard
|
|
10313
|
+
const accessGuard = this.placeRouter.accessGuard$.value;
|
|
10308
10314
|
if (placeDefinition.authenticate) {
|
|
10309
10315
|
const authenticated = await accessGuard.isAuthenticated();
|
|
10310
|
-
if (!authenticated
|
|
10316
|
+
if (!authenticated) {
|
|
10311
10317
|
const redirectLocation = this.placeRouter.getAuthenticationFailureRedirect(activatedRoute, state);
|
|
10312
10318
|
const nextPlaceDef = this.getPlaceDefinition(redirectLocation);
|
|
10313
10319
|
if (nextPlaceDef.authenticate) {
|
|
10314
|
-
lang.illegalState(`
|
|
10320
|
+
lang.illegalState(`onAuthenticationFailure hook returned place ${nextPlaceDef.component.name} that requires authentication.`);
|
|
10315
10321
|
}
|
|
10316
10322
|
return this.createUrlTree(redirectLocation);
|
|
10317
10323
|
}
|
|
10324
|
+
if (!accessGuard.isAuthorised(placeDefinition) && !placeDefinition.redirectToFirstChild) {
|
|
10325
|
+
const redirectOptions = this.placeRouter.getAuthorisationFailureRedirectOptions(activatedRoute.component);
|
|
10326
|
+
const nextRedirect = redirectOptions.find(it => accessGuard.isAuthorised(this.getPlaceDefinition(it)));
|
|
10327
|
+
if (!nextRedirect) {
|
|
10328
|
+
lang.illegalState(`onAuthorisationFailure hook didn't return any authorised locations: ${redirectOptions.map(it => this.getPlaceDefinition(it).component.name).join(', ')}`);
|
|
10329
|
+
}
|
|
10330
|
+
return this.createUrlTree(nextRedirect);
|
|
10331
|
+
}
|
|
10318
10332
|
}
|
|
10319
10333
|
const result = await this.cleanInteractionState(activatedRoute, state, async () => {
|
|
10320
10334
|
const navigationSession = this.placeRouter.navigationSession;
|