mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-19 12:52:55 +12:00
improvement: support multiple otp apps w/resources
This commit is contained in:
parent
8539afc62b
commit
a1be3c6523
1 changed files with 10 additions and 6 deletions
|
@ -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
|
||||
|> 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 """
|
||||
|
|
Loading…
Reference in a new issue