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