evaluate method

All supplied conditions must pass. Empty or throwing policies deny access. Async loading and error states never grant access.

Implementation

AuthorizationResult evaluate(
  UserSecurityContext context,
  ZenithPolicy policy,
) {
  final state = evaluateState(context, policy);
  return AuthorizationResult(
    isAuthorized: state is AsyncData<bool> && state.value,
    reason: state is AsyncLoading<bool> ? 'Pending async evaluation' : null,
  );
}