fix: set tenant in sign_in and reset_route (#478)

This commit is contained in:
Zach Daniel 2024-07-16 15:31:48 -04:00 committed by GitHub
parent 1114d929d2
commit ef856bf14e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -183,13 +183,17 @@ defmodule AshAuthentication.Phoenix.Router do
end)
live_session_opts = [
session: %{
"overrides" => unquote(overrides),
"otp_app" => unquote(otp_app),
"path" => unquote(path),
"reset_path" => unquote(reset_path),
"register_path" => unquote(register_path)
},
session:
{AshAuthentication.Phoenix.Router, :generate_session,
[
%{
"overrides" => unquote(overrides),
"otp_app" => unquote(otp_app),
"path" => unquote(path),
"reset_path" => unquote(reset_path),
"register_path" => unquote(register_path)
}
]},
on_mount: on_mount
]
@ -295,7 +299,9 @@ defmodule AshAuthentication.Phoenix.Router do
end)
live_session_opts = [
session: %{"overrides" => unquote(overrides), "otp_app" => unquote(otp_app)},
session:
{AshAuthentication.Phoenix.Router, :generate_session,
[%{"overrides" => unquote(overrides), "otp_app" => unquote(otp_app)}]},
on_mount: on_mount
]
@ -314,4 +320,9 @@ defmodule AshAuthentication.Phoenix.Router do
end
end
end
@doc false
def generate_session(conn, session) do
Map.put(session, "tenant", Ash.PlugHelpers.get_tenant(conn))
end
end