Hi everyone,
I’m trying to get the password reset function working from mix phx.gen.auth
. Here is a snippet of the code:
defmodule LichtmalerElixirWeb.UserResetPasswordController do
use LichtmalerElixirWeb, :controller
alias LichtmalerElixir.Accounts
require Logger
plug :get_user_by_reset_password_token when action in [:edit, :update]
def new(conn, _params) do
Logger.alert("new")
render(conn, "new.html")
end
#%{"user" => %{"email" => email}} =
def create(conn, params) do
Logger.alert("create")
...
conn
|> put_flash(
:info,
gettext("Wenn sich Ihre E-Mail-Adresse in unserem System befindet, " <>
"erhalten Sie in Kürze Anweisungen zum Zurücksetzen Ihres Passworts.")
)
|> redirect(to: "/")
end
...
Going to the page and calling the function with an existing email does not work as expected. The create function is never called, as you can see in the logs:
[info] GET /users/reset_password
[debug] Processing with LichtmalerElixirWeb.UserResetPasswordController.new/2
Parameters: %{"l" => "de"}
Pipelines: [:browser, :redirect_if_user_is_authenticated]
[alert] new
[info] Sent 200 in 7ms
[info] POST /users/reset_password
[debug] Processing with LichtmalerElixirWeb.UserResetPasswordController.create/2
Parameters: %{"_csrf_token" => "...", "user" => %{"email" => "some@email.de"}}
Pipelines: [:browser, :redirect_if_user_is_authenticated]
[info] Sent 302 in 1ms
[debug] Phoenix.Router halted in :browser/2
[info] GET /users/reset_password
[debug] Processing with LichtmalerElixirWeb.UserResetPasswordController.new/2
Parameters: %{"l" => "de"}
Pipelines: [:browser, :redirect_if_user_is_authenticated]
[alert] new
[info] Sent 200 in 2ms
I have no idea how to debug this properly. Disabling plugs didn’t lead to any results.
Is this a known issue? Do you have any ideas how to solve this? I appreciate any help.
Thanks!
Benjamin