search-backend: handle missing type configuration in AuthorizedSearchEngine
The search-backend router ensures that all requested types are configured, but since we don't know how this search engine will be used, it's good to properly handle the case where an unconfigured type is supplied. Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
committed by
MT Lewis
parent
32e4645930
commit
bdbacb3b9c
@@ -90,13 +90,13 @@ export class AuthorizedSearchEngine implements SearchEngine {
|
||||
const authorizer = new DataLoader((requests: readonly AuthorizeQuery[]) =>
|
||||
this.permissions.authorize(requests.slice(), options),
|
||||
);
|
||||
|
||||
const requestedTypes = query.types || Object.keys(this.types);
|
||||
|
||||
const typeDecisions = zipObject(
|
||||
requestedTypes,
|
||||
await Promise.all(
|
||||
requestedTypes.map(type => {
|
||||
const permission = this.types[type].visibilityPermission;
|
||||
const permission = this.types[type]?.visibilityPermission;
|
||||
|
||||
return permission
|
||||
? authorizer.load({ permission })
|
||||
@@ -162,7 +162,7 @@ export class AuthorizedSearchEngine implements SearchEngine {
|
||||
return result;
|
||||
}
|
||||
|
||||
const permission = this.types[result.type].visibilityPermission;
|
||||
const permission = this.types[result.type]?.visibilityPermission;
|
||||
const resourceRef = result.document.authorization?.resourceRef;
|
||||
|
||||
if (!permission || !resourceRef) {
|
||||
|
||||
Reference in New Issue
Block a user