Pow: Allow route paths to be customized

Created on 14 Aug 2019  路  3Comments  路  Source: danschultzer/pow

By default when using pow_routes() the paths for all routes are generated such as:

/session/new
/registration/new

I'd like to be able to have my route paths defined as:

/sign_up
/sign_in

Is there currently a way to do this?

Most helpful comment

They can be overridden, the same way you would override routes normally in Phoenix:

defmodule MyAppWeb.Router do
  use MyAppWeb, :router
  use Pow.Phoenix.Router

  # ...

  scope "/", Pow.Phoenix, as: "pow" do
    get "/sign_up", RegistrationController, :new
    post "/sign_up", RegistrationController, :create
    get "/sign_in", SessionController, :new
    post "/sign_in", SessionController, :create
  end

  scope "/" do
    pow_routes()
  end

  # ...
end

All 3 comments

I think you can find an example for custom routes here: https://github.com/danschultzer/pow/blob/master/guides/custom_controllers.md

They can be overridden, the same way you would override routes normally in Phoenix:

defmodule MyAppWeb.Router do
  use MyAppWeb, :router
  use Pow.Phoenix.Router

  # ...

  scope "/", Pow.Phoenix, as: "pow" do
    get "/sign_up", RegistrationController, :new
    post "/sign_up", RegistrationController, :create
    get "/sign_in", SessionController, :new
    post "/sign_in", SessionController, :create
  end

  scope "/" do
    pow_routes()
  end

  # ...
end

thanks @danschultzer that is exactly what I was looking for.

Was this page helpful?
0 / 5 - 0 ratings