mirror of
https://github.com/ash-project/ash_oban.git
synced 2024-09-20 05:13:15 +12:00
28 lines
791 B
Elixir
28 lines
791 B
Elixir
defmodule AshOban.Checks.AshObanInteraction do
|
|
@moduledoc """
|
|
This check is true if the context `private.ash_oban?` is set to true.
|
|
|
|
This context will only ever be set in code that is called internally by
|
|
`ash_oban`, allowing you to create a bypass in your policies on your
|
|
user/user_token resources.
|
|
|
|
```elixir
|
|
policies do
|
|
bypass AshObanInteraction do
|
|
authorize_if always()
|
|
end
|
|
end
|
|
```
|
|
"""
|
|
use Ash.Policy.SimpleCheck
|
|
|
|
@impl Ash.Policy.Check
|
|
def describe(_) do
|
|
"AshOban is performing this interaction"
|
|
end
|
|
|
|
@impl Ash.Policy.SimpleCheck
|
|
def match?(_, %{query: %{context: %{private: %{ash_oban?: true}}}}, _), do: true
|
|
def match?(_, %{changeset: %{context: %{private: %{ash_oban?: true}}}}, _), do: true
|
|
def match?(_, _, _), do: false
|
|
end
|