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:
parent
a3cd43d2c2
commit
837e2ea13f
1 changed files with 7 additions and 10 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue