↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Real World Phoenix |> Let's auth some users |> Pow!

The post introduces Pow as a way to add user authentication to a Phoenix app while keeping the Elixir style explicit and modular. It uses a student manager app as the example and focuses on getting registration and session-based authentication running quickly.

Reading notes
#

  • Pow is presented as a new option for user authentication in Elixir and Phoenix.
  • The author prefers it because it fits an explicit and modular Elixir mindset.
  • The example app starts from a Live View Dashboard starter template with Ecto and Postgres added.
  • The setup begins by adding the Pow dependency to mix.exs and running mix deps.get.
  • mix pow.install creates a user file and a migration.
  • The author changes the generated users/user.ex path to accounts/user.ex and configures Pow to use Studentmanager.Accounts.User and StudentManager.Repo.
  • A session plug is added in the endpoint with Pow.Plug.Session.
  • pow_routes() adds routes for registration and authentication.
  • A protected pipeline uses Pow.Plug.RequireAuthenticated with Pow.Phoenix.PlugErrorHandler.
  • After mix ecto.setup, the app can create a new user at /registration/new.
  • The conclusion says Pow makes registration and session-based authentication straightforward, with customization options and template generation available for further adaptation.