AshBilling.Checks.Subscribed (ash_billing v0.1.1)

Copy Markdown View Source

An Ash policy check that authorizes if the current actor has an active billing subscription.

Can be used as a simple check without options, or with a :price option to require a specific tier.

Usage

policies do
  # Authorize any active subscription
  policy action(:generate_report) do
    authorize_if AshBilling.Checks.Subscribed
  end

  # Authorize only users subscribed to a specific price/tier
  policy action(:export_enterprise_data) do
    authorize_if {AshBilling.Checks.Subscribed, price: "price_enterprise_annual"}
  end
end

Options

  • :price - An optional price identifier to require.
  • :domain - The Ash domain to use when lazy-loading subscriptions (defaults to the domain in context).

Summary

Functions

eager_evaluate?()

Callback implementation for Ash.Policy.Check.eager_evaluate?/0.

init(opts)

Callback implementation for Ash.Policy.Check.init/1.

prefer_expanded_description?()

Callback implementation for Ash.Policy.Check.prefer_expanded_description?/0.

requires_original_data?(_, _)

Callback implementation for Ash.Policy.Check.requires_original_data?/2.

strict_check(actor, context, opts)

Callback implementation for Ash.Policy.Check.strict_check/3.

type()

Callback implementation for Ash.Policy.Check.type/0.