Lines 1156-1196javascript
1156 const permissions = Array.isArray(params.permission) ? params.permission : [params.permission];
1157 if (permissions.length === 0) return false;
1158 for (const permission of permissions) {
1159 const checkOptions = this.buildCheckOptions(user, { ...params, permission });
1160 if (!checkOptions) continue;
1162 const result = await this.workos.authorization.check(checkOptions);
1163 if (result.authorized) return true;
1165 if (isWorkOSResourceNotFoundError(error)) continue;
1172 * Require that a user has permission, throwing FGADeniedError if not.
1174 * When `params.permission` is an array, ANY-of semantics apply: passes if any
1175 * single permission authorizes the user; throws if none do.
1177 async require(user, params) {
1178 const permissions = Array.isArray(params.permission) ? params.permission : [params.permission];
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/index.jsView on unpkg · L1176 1179 if (permissions.length === 0) {
1180 throw new FGADeniedError(user, params.resource, params.permission);
1183 for (const permission of permissions) {
1184 const checkOptions = this.buildCheckOptions(
1186 { ...params, permission },
1187 { strictMembershipResolution: true }
1189 if (!checkOptions) continue;
1191 const result = await this.workos.authorization.check(checkOptions);
1192 if (result.authorized) return;
1194 if (error instanceof FGADeniedError) throw error;
1195 if (isWorkOSResourceNotFoundError(error)) continue;