📎 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.exsand runningmix deps.get. mix pow.installcreates a user file and a migration.- The author changes the generated
users/user.expath toaccounts/user.exand configures Pow to useStudentmanager.Accounts.UserandStudentManager.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.RequireAuthenticatedwithPow.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.
