From 3274087429d68d16c8d31d7507724c6664f596e9 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 23 Feb 2023 02:39:27 -0500 Subject: [PATCH] improvement: support multiple otp apps w/resources (#209) --- lib/ash_authentication.ex | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ash_authentication.ex b/lib/ash_authentication.ex index 2406ca5d..bae2451b 100644 --- a/lib/ash_authentication.ex +++ b/lib/ash_authentication.ex @@ -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 """