@christianacca/angular-swa-auth
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -903,3 +903,3 @@ (function (global, factory) { | ||
this.allowedRoles = new rxjs.ReplaySubject(1); | ||
this.userRoles = new rxjs.ReplaySubject(1); | ||
this.userRolesFromTemplate = new rxjs.ReplaySubject(1); | ||
this.subscription = new rxjs.Subscription(); | ||
@@ -913,2 +913,5 @@ this.context = (_a = {}, | ||
set: function (value) { | ||
// we're ignoring null/undefined to accommodate async fetching of allowed roles in the consumer template. In this | ||
// scenario the async pipe will initially assign a null to our input property. We skip this so that the initial | ||
// placeholder authz result will be in play until the allowed roles are finally fetched | ||
if (value == null) | ||
@@ -923,3 +926,8 @@ return; | ||
set: function (value) { | ||
this.userRoles.next(value); | ||
// we're ignoring null/undefined to accommodate async fetching of user roles in the consumer template. In this | ||
// scenario the async pipe will initially assign a null to our input property. We skip this so that the initial | ||
// placeholder authz result will be in play until the user roles are finally fetched | ||
if (value == null) | ||
return; | ||
this.userRolesFromTemplate.next(value); | ||
}, | ||
@@ -931,4 +939,4 @@ enumerable: false, | ||
var _this = this; | ||
var injectedRoles$ = this.authService.userLoaded$.pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.userRoles; }), operators.takeUntil(this.userRoles)); | ||
var userRoles$ = rxjs.merge(this.userRoles, injectedRoles$).pipe(operators.map(function (x) { return x !== null && x !== void 0 ? x : noExplicitRoles; })); | ||
var injectedRoles$ = this.authService.userLoaded$.pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.userRoles; }), operators.takeUntil(this.userRolesFromTemplate)); | ||
var userRoles$ = rxjs.merge(this.userRolesFromTemplate, injectedRoles$).pipe(operators.map(function (x) { return x !== null && x !== void 0 ? x : noExplicitRoles; })); | ||
var permissionCheck$ = rxjs.combineLatest([this.allowedRoles, userRoles$]).pipe(operators.map(function (_a) { | ||
@@ -935,0 +943,0 @@ var _b = __read(_a, 2), allowedRoles = _b[0], userRoles = _b[1]; |
@@ -33,3 +33,3 @@ import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core'; | ||
this.allowedRoles = new ReplaySubject(1); | ||
this.userRoles = new ReplaySubject(1); | ||
this.userRolesFromTemplate = new ReplaySubject(1); | ||
this.subscription = new Subscription(); | ||
@@ -42,2 +42,5 @@ this.context = { | ||
set swaRoleCheckOf(value) { | ||
// we're ignoring null/undefined to accommodate async fetching of allowed roles in the consumer template. In this | ||
// scenario the async pipe will initially assign a null to our input property. We skip this so that the initial | ||
// placeholder authz result will be in play until the allowed roles are finally fetched | ||
if (value == null) | ||
@@ -48,7 +51,12 @@ return; | ||
set swaRoleCheckUserRoles(value) { | ||
this.userRoles.next(value); | ||
// we're ignoring null/undefined to accommodate async fetching of user roles in the consumer template. In this | ||
// scenario the async pipe will initially assign a null to our input property. We skip this so that the initial | ||
// placeholder authz result will be in play until the user roles are finally fetched | ||
if (value == null) | ||
return; | ||
this.userRolesFromTemplate.next(value); | ||
} | ||
ngOnInit() { | ||
const injectedRoles$ = this.authService.userLoaded$.pipe(map(user => user === null || user === void 0 ? void 0 : user.userRoles), takeUntil(this.userRoles)); | ||
const userRoles$ = merge(this.userRoles, injectedRoles$).pipe(map(x => x !== null && x !== void 0 ? x : noExplicitRoles)); | ||
const injectedRoles$ = this.authService.userLoaded$.pipe(map(user => user === null || user === void 0 ? void 0 : user.userRoles), takeUntil(this.userRolesFromTemplate)); | ||
const userRoles$ = merge(this.userRolesFromTemplate, injectedRoles$).pipe(map(x => x !== null && x !== void 0 ? x : noExplicitRoles)); | ||
const permissionCheck$ = combineLatest([this.allowedRoles, userRoles$]).pipe(map(([allowedRoles, userRoles]) => hasSomeAllowedRoles(allowedRoles, userRoles))); | ||
@@ -55,0 +63,0 @@ this.subscription = permissionCheck$.subscribe(authzResult => { |
@@ -505,3 +505,3 @@ import { HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http'; | ||
this.allowedRoles = new ReplaySubject(1); | ||
this.userRoles = new ReplaySubject(1); | ||
this.userRolesFromTemplate = new ReplaySubject(1); | ||
this.subscription = new Subscription(); | ||
@@ -514,2 +514,5 @@ this.context = { | ||
set swaRoleCheckOf(value) { | ||
// we're ignoring null/undefined to accommodate async fetching of allowed roles in the consumer template. In this | ||
// scenario the async pipe will initially assign a null to our input property. We skip this so that the initial | ||
// placeholder authz result will be in play until the allowed roles are finally fetched | ||
if (value == null) | ||
@@ -520,7 +523,12 @@ return; | ||
set swaRoleCheckUserRoles(value) { | ||
this.userRoles.next(value); | ||
// we're ignoring null/undefined to accommodate async fetching of user roles in the consumer template. In this | ||
// scenario the async pipe will initially assign a null to our input property. We skip this so that the initial | ||
// placeholder authz result will be in play until the user roles are finally fetched | ||
if (value == null) | ||
return; | ||
this.userRolesFromTemplate.next(value); | ||
} | ||
ngOnInit() { | ||
const injectedRoles$ = this.authService.userLoaded$.pipe(map(user => user === null || user === void 0 ? void 0 : user.userRoles), takeUntil(this.userRoles)); | ||
const userRoles$ = merge(this.userRoles, injectedRoles$).pipe(map(x => x !== null && x !== void 0 ? x : noExplicitRoles)); | ||
const injectedRoles$ = this.authService.userLoaded$.pipe(map(user => user === null || user === void 0 ? void 0 : user.userRoles), takeUntil(this.userRolesFromTemplate)); | ||
const userRoles$ = merge(this.userRolesFromTemplate, injectedRoles$).pipe(map(x => x !== null && x !== void 0 ? x : noExplicitRoles)); | ||
const permissionCheck$ = combineLatest([this.allowedRoles, userRoles$]).pipe(map(([allowedRoles, userRoles]) => hasSomeAllowedRoles(allowedRoles, userRoles))); | ||
@@ -527,0 +535,0 @@ this.subscription = permissionCheck$.subscribe(authzResult => { |
@@ -25,5 +25,5 @@ import { OnDestroy, OnInit, TemplateRef, ViewContainerRef } from '@angular/core'; | ||
set swaRoleCheckOf(value: string[]); | ||
set swaRoleCheckUserRoles(value: string[] | undefined); | ||
set swaRoleCheckUserRoles(value: string[]); | ||
private allowedRoles; | ||
private userRoles; | ||
private userRolesFromTemplate; | ||
private subscription; | ||
@@ -30,0 +30,0 @@ private context; |
{ | ||
"name": "@christianacca/angular-swa-auth", | ||
"description": "Programmatically work with Azure Static Web Apps authentication in an angular app", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "azure", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
338950
3388