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

@@ -64,7 +64,7 @@ defmodule SimpleshopThemeWeb.Auth.ConfirmationTest do
assert Accounts.get_user!(user.id).confirmed_at
# we are logged in now
assert get_session(conn, :user_token)
assert redirected_to(conn) == ~p"/"
assert redirected_to(conn) == ~p"/admin"
# log out, new conn
conn = build_conn()

View File

@@ -56,7 +56,7 @@ defmodule SimpleshopThemeWeb.Auth.LoginTest do
conn = submit_form(form, conn)
assert redirected_to(conn) == ~p"/"
assert redirected_to(conn) == ~p"/admin"
end
test "redirects to login page with a flash error if credentials are invalid", %{

View File

@@ -25,7 +25,7 @@ defmodule SimpleshopThemeWeb.Auth.RegistrationTest do
conn
|> log_in_user(user_fixture())
|> live(~p"/users/register")
|> follow_redirect(conn, ~p"/")
|> follow_redirect(conn, ~p"/admin")
assert {:ok, _conn} = result
end