Fix CSRF token error in impersonation banner

Replace raw HTML form with Phoenix .link helper using method="delete" to properly handle CSRF token in LiveView context. This fixes the UndefinedFunctionError when accessing /admin route.
This commit is contained in:
Graham McIntire 2026-01-06 12:58:17 -06:00
parent a3cd43d2c2
commit 837e2ea13f
No known key found for this signature in database

View file

@ -87,16 +87,13 @@ defmodule ToweropsWeb.Layouts do
Impersonating: {@current_scope.user.email}
</span>
</div>
<form action={~p"/admin/impersonate"} method="post">
<input type="hidden" name="_csrf_token" value={Phoenix.Controller.get_csrf_token()} />
<input type="hidden" name="_method" value="delete" />
<button
type="submit"
class="px-3 py-1 bg-white text-yellow-900 hover:bg-yellow-50 rounded font-medium text-sm"
>
Exit Impersonation
</button>
</form>
<.link
href={~p"/admin/impersonate"}
method="delete"
class="px-3 py-1 bg-white text-yellow-900 hover:bg-yellow-50 rounded font-medium text-sm"
>
Exit Impersonation
</.link>
</div>
</div>
</div>