fix signed_in_path to always redirect to /admin after login

Single-tenant app: every user is the admin. The previous pattern
match on conn.assigns.current_scope didn't work for first-time
logins because the scope isn't assigned to the conn yet at that
point, causing the fallback to ~p"/" instead of ~p"/admin".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-12 14:55:57 +00:00
parent 9251beba68
commit fdb09128b4
6 changed files with 10 additions and 14 deletions

View File

@@ -257,12 +257,8 @@ defmodule SimpleshopThemeWeb.UserAuth do
end
@doc "Returns the path to redirect to after log in."
# the user was already logged in, redirect to admin dashboard
def signed_in_path(%Plug.Conn{assigns: %{current_scope: %Scope{user: %Accounts.User{}}}}) do
~p"/admin"
end
def signed_in_path(_), do: ~p"/"
# Single-tenant: every user is the admin, always go to dashboard
def signed_in_path(_), do: ~p"/admin"
@doc """
Plug for routes that require the user to be authenticated.