Add login next url parameter for auth redirects
This commit is contained in:
@@ -163,11 +163,11 @@ defmodule SsoBsnWeb.UserAuth do
|
||||
end
|
||||
end
|
||||
|
||||
def on_mount(:redirect_if_user_is_authenticated, _params, session, socket) do
|
||||
def on_mount(:redirect_if_user_is_authenticated, params, session, socket) do
|
||||
socket = mount_current_user(socket, session)
|
||||
|
||||
if socket.assigns.current_user do
|
||||
{:halt, Phoenix.LiveView.redirect(socket, to: signed_in_path(socket))}
|
||||
{:halt, Phoenix.LiveView.redirect(socket, to: signed_in_path(params["next"]))}
|
||||
else
|
||||
{:cont, socket}
|
||||
end
|
||||
@@ -224,5 +224,7 @@ defmodule SsoBsnWeb.UserAuth do
|
||||
|
||||
defp maybe_store_return_to(conn), do: conn
|
||||
|
||||
defp signed_in_path(_conn), do: ~p"/users/settings"
|
||||
defp signed_in_path(%Plug.Conn{ query_params: %{ "next" => next }}), do: ~p"/redirect?next=#{next}"
|
||||
defp signed_in_path(next) when is_binary(next), do: ~p"/redirect?next=#{next}"
|
||||
defp signed_in_path(_), do: ~p"/users/settings"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user