This short course implements JWT-based authentication in Elixir using the Phoenix framework, the MVC framework often compared to Express for Node.js, but built on the same Erlang foundation that powers systems at WhatsApp, Discord, and Pinterest.
The authentication flow you'll build
- User registration, storing email, password, and username in PostgreSQL
- One-way password hashing instead of storing plain text
- Login that validates the password hash and issues a JWT for protected routes
- Fetching the authenticated user from a token without ever exposing the password
- Logout, implemented by invalidating a token against the user's ID in the database
Because JWTs can't be destroyed outright, the course also covers the practical workaround of tracking invalidated tokens so a logged-out token can't be reused against protected routes.