Skip to content

Commit

Permalink
improvement: support multiple otp apps w/resources (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Feb 23, 2023
1 parent 8539afc commit 3274087
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/ash_authentication.ex
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,18 @@ defmodule AshAuthentication do
[Example.User, Example.UserWithTokenRequired]
"""
@spec authenticated_resources(atom) :: [Resource.t()]
@spec authenticated_resources(atom | [atom]) :: [Resource.t()]
def authenticated_resources(otp_app) do
otp_app
|> Application.get_env(:ash_apis, [])
|> Stream.flat_map(&Api.Info.resources(&1))
|> Stream.uniq()
|> Stream.filter(&(AshAuthentication in Spark.extensions(&1)))
|> Enum.to_list()
|> List.wrap()
|> Enum.flat_map(fn otp_app ->
otp_app
|> Application.get_env(:ash_apis, [])
|> Stream.flat_map(&Api.Info.resources(&1))
|> Stream.uniq()
|> Stream.filter(&(AshAuthentication in Spark.extensions(&1)))
|> Enum.to_list()
end)
end

@doc """
Expand Down

0 comments on commit 3274087

Please sign in to comment.