Lately, I've been delving into Angular 11 and attempting to create a function that verifies account permissions for a specific action based on changes in the SAS Token. Below are the functions I have implemented:
/**
* Verify if SAS has permissions
* @param sasUri Sas address
* @param permissions The permissions to verify
* @returns Boolean Value
*/
async hasPermissions(sasUri: string, permissions: SASInformationPermission[]): Promise<boolean> {
const permissionAccount = await this.getSASUriInformation(sasUri).toPromise();
return permissions.every((permission) => {
permissionAccount.signedPermissions.includes(permission);
});
}
/**
* Get validation of action permission
* @param sasUri Sas address
* @param action The action to check
* @returns Boolean value
*/
hasActionPermission(sasUri: string, action: Action): Observable<boolean> {
return defer(async () => {
let permission: SASInformationPermission[];
if (action === 'upload') {
permission = [
SASInformationPermission.Read,
SASInformationPermission.List,
SASInformationPermission.Write,
];
} else {
permission = [SASInformationPermission.List, SASInformationPermission.Read];
}
return await this.hasPermissions(sasUri, permission);
});
}
The "hasPermissions" function checks if the SAS has the necessary access rights for a specified action passed as a parameter. Conversely, the "HasActionPermission" function invokes the above function to obtain a Boolean value.
If the function "HasActionPermission" fails to enter the "return defer" block, what could be causing this issue?