AshMultiAccount.Phoenix.Router (AshMultiAccount v0.1.1)

Copy Markdown View Source

Provides the multi_account_routes/3 macro for generating multi-account routes.

Usage

defmodule MyAppWeb.Router do
  use Phoenix.Router
  use AshMultiAccount.Phoenix.Router

  scope "/", MyAppWeb do
    pipe_through :browser
    multi_account_routes MultiAccountController, MyApp.Accounts.User
  end
end

This generates:

get  "/link/p/:primary_user_id", MultiAccountController, :link_account
post "/link/p/:primary_user_id", MultiAccountController, :link_account
get  "/link/switch_to/:user_id", MultiAccountController, :switch_to_account

Custom Paths

multi_account_routes MyController, MyUser,
  link_path: "/accounts/link/:primary_user_id",
  switch_path: "/accounts/switch/:user_id"

Summary

Functions

Generates routes for multi-account link and switch actions.

Functions

multi_account_routes(controller, user_resource, opts \\ [])

(macro)

Generates routes for multi-account link and switch actions.