Greetings Seniors,
I installed Pow for auth, with email confirmation and password reset extensions along with the necessary configs, templates gen, routes, based on the doc.
Firstly, on browser pipe, the sign in, sign out work fine but not the password reset (neither email confirmation).
The routes from pow_extension_routes enable /reset-password/:id (and for email).
-
Expected: enter email on password reset view, receive the mail with reset url which redirects to password resetting view.
-
Although it sends the mail, with the reset link like as /reset-password/<token>, going to that url gets into Phoenix.NotAcceptableError format expected one of ["html"]. Since it is a token with lots of dots.
But I can't determine whether it is my Phoenix based configuration, or a Pow based error, as it should be working and accept the endpoint according to docs, forums I went through.
config :myapp, :pow,
user: MyApp.Users.User,
repo: MyApp.Repo,
web_module: MyAppWeb,
web_mailer_module: MyAppWeb,
mailer_backend: MyAppWeb.PowMailer,
extensions: [PowEmailConfirmation, PowResetPassword],
controller_callbacks: Pow.Extension.Phoenix.ControllerCallbacks,
credentials_cache_store: {Pow.Store.CredentialsCache, reload: true}
defmodule MyAppWeb.Router do
use MyAppWeb, :router
use Pow.Phoenix.Router
use Pow.Extension.Phoenix.Router, extensions: [PowEmailConfirmation, PowResetPassword]
pipeline :browser do
plug :accepts, ["html"] # The same server accept in every blogs and doc, from the client header there are html, text, */* wildcards
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {MyAppWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :protected do
plug Pow.Plug.RequireAuthenticated, error_handler: Pow.Phoenix.PlugErrorHandler
end
pipeline :api do
plug :accepts, ["json"]
plug MyAppWeb.Guard.APIAuthPlug, otp_app: :myapp
end
pipeline :api_protected do
plug Pow.Plug.RequireAuthenticated, error_handler: MyAppWeb.Guard.APIAuthErrorHandler
end
pipeline :api_not_protected do
plug Pow.Plug.RequireNotAuthenticated, error_handler: MyAppWeb.Guard.APIAuthErrorHandler
end
pipeline :admin do
plug MyAppWeb.Guard.EnsureRolePlug, :admin
end
scope "/", MyAppWeb do
pipe_through :browser
get "/", PageController, :home
end
scope "/" do
pipe_through :browser
pow_session_routes()
pow_extension_routes()
resources "/registration", Pow.Phoenix.RegistrationController, singleton: true, only: [:edit, :update]
end
scope "/admin", MyAppWeb, as: :admin do
pipe_through [:browser, :protected, :api, :api_protected, :admin]
scope "/v1", API.V1, as: :v1 do
get "/users", UserController, :index
end
end
...
end
# Reset link example: http://localhost:4000/reset-password/SFMyNTY.MTJkNDliZWItZTg2My00ZDM3LTg2YzgtYzE5MDdjMDk5ODgz.kFRCfvdOSeEnupbbujdAKoaCuMXXk91qzZCUMrB43mw
[debug] ** (Phoenix.NotAcceptableError) unknown format "kFRCfvdOSeEnupbbujdAKoaCuMXXk91qzZCUMrB43mw", expected one of ["html"]
(phoenix 1.7.21) lib/phoenix/controller.ex:1521: Phoenix.Controller.handle_params_accept/3
(myapp 0.1.0) MyAppWeb.Router.browser/2
(myapp 0.1.0) lib/myapp_web/router.ex:1: MyAppWeb.Router.__pipe_through0__/1
(phoenix 1.7.21) lib/phoenix/router.ex:475: Phoenix.Router.__call__/5
(myapp 0.1.0) lib/myapp_web/endpoint.ex:1: MyAppWeb.Endpoint.plug_builder_call/2
(myapp 0.1.0) deps/plug/lib/plug/debugger.ex:155: MyAppWeb.Endpoint."call (overridable 3)"/2
(myapp 0.1.0) lib/myapp_web/endpoint.ex:1: MyAppWeb.Endpoint.call/2
(phoenix 1.7.21) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
Please, any idea how to debug, or more resources? Thank you!
Greetings Seniors,
I installed Pow for auth, with email confirmation and password reset extensions along with the necessary configs, templates gen, routes, based on the doc.
Firstly, on browser pipe, the sign in, sign out work fine but not the password reset (neither email confirmation).
The routes from
pow_extension_routesenable/reset-password/:id(and for email).Expected: enter email on password reset view, receive the mail with reset url which redirects to password resetting view.
Although it sends the mail, with the reset link like as
/reset-password/<token>, going to that url gets intoPhoenix.NotAcceptableError format expected one of ["html"]. Since it is a token with lots of dots.But I can't determine whether it is my Phoenix based configuration, or a Pow based error, as it should be working and accept the endpoint according to docs, forums I went through.
Please, any idea how to debug, or more resources? Thank you!