-
-
Notifications
You must be signed in to change notification settings - Fork 158
Open
Description
I am trying to set up Pow with multiple user schemas. I followed the instructions here but I am unable to get it to work. I've tried to find a solution in the documentation but I didn't find a solution.
Using Elixir 1.10.3, Phoenix 1.5.1 and Pow 1.0.20.
The error I get in the browser is the following,
UndefinedFunctionError at GET /organizer/session/new
function HelloWeb.Router.Helpers.pow_session_path/3 is undefined or private
When compiling organizer_routes.ex
, I get the warning warning: this clause cannot match because a previous clause at line 2 always matches
. I am suspecting this is related to why the routes aren't working
Below are all the configuration changes I have made
# lib/hello_web/organizer_routes.ex
defmodule HelloWeb.Pow.OrganizerRoutes do
use Pow.Phoenix.Routes
def path_for(conn, verb, vars \\ [], query_params \\ []) do
plug = Module.concat(["OrganizerPow", verb])
Pow.Phoenix.Routes.path_for(conn, plug, vars, query_params)
end
def url_for(conn, verb, vars \\ [], query_params \\ []) do
plug = Module.concat(["OrganizerPow", verb])
Pow.Phoenix.Routes.url_for(conn, plug, vars, query_params)
end
end
# lib/hello_web/router.ex
defmodule HelloWeb.Router do
use HelloWeb, :router
use Pow.Phoenix.Router
# ...
pipeline :pow_organizer do
plug :set_pow_config,
repo: Hello.Repo,
user: Hello.Organizers.Organizer,
current_user_assigns_key: :current_organizer,
session_key: "organizer_auth",
routes_backend: HelloWeb.Pow.OrganizerRoutes,
plug: Pow.Plug.Session
end
defp set_pow_config(conn, config), do: Pow.Plug.put_config(conn, config)
# I've temporarily disabled these routes since it seems Pow otherwise uses these for the organizer user schema as well
# scope "/" do
# pipe_through :browser
# pow_routes()
# end
scope "/", HelloWeb do
pipe_through :browser
get "/", PageController, :index
end
scope "/organizer", as: :organizer do
pipe_through [:browser, :pow_organizer]
pow_routes()
end
# ...
end
# lib/hello_web/endpoint.ex
defmodule HelloWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :hello
# ...
plug Plug.Session, @session_options
plug Pow.Plug.Session,
repo: Hello.Repo,
user: Hello.Users.Organizer,
current_user_assigns_key: :current_organizer,
session_key: "organizer_auth"
plug Pow.Plug.Session,
user: Hello.Users.User,
repo: Hello.Repo,
current_user_assigns_key: :current_user,
session_key: "user_auth"
plug HelloWeb.Router
end
Metadata
Metadata
Assignees
Labels
No labels