From f9e0481cc6b2ae94e7ddd58047d2e7a1227802ff Mon Sep 17 00:00:00 2001 From: olafbado Date: Wed, 13 Mar 2024 12:29:16 +0100 Subject: [PATCH] fix: Fix extract_resource_module fn --- lib/permit_phoenix/live_view/authorize_hook.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/permit_phoenix/live_view/authorize_hook.ex b/lib/permit_phoenix/live_view/authorize_hook.ex index 9ba6c70..3fdbcfa 100644 --- a/lib/permit_phoenix/live_view/authorize_hook.ex +++ b/lib/permit_phoenix/live_view/authorize_hook.ex @@ -251,13 +251,13 @@ defmodule Permit.Phoenix.LiveView.AuthorizeHook do end) end - defp extract_resource_module(events, action, default) do + defp extract_resource_module(events, action, default_resource_module) do action = Atom.to_string(action) events - |> Enum.find({nil, default}, fn {event, _resource_module} -> + |> Enum.find({nil, nil}, fn {event, _resource_module} -> event == action end) - |> then(fn {_, resource_module} -> resource_module end) + |> then(fn {_, resource_module} -> resource_module || default_resource_module end) end end