Protect Routes with Plugs
Explore how to use plugs in Phoenix to protect web routes by managing authenticated user sessions. Learn to fetch the current user, authenticate login credentials, and handle redirections to secure your application effectively.
We'll cover the following...
We'll cover the following...
The authentication service integrates with the Phoenix stack to provide infrastructure for session management including plugs that we can use in the router to control access to our routes.
Defining the authentication service
The authentication service is defined in the file pento/lib/pento_web/controllers/user_auth.ex. We could open up the code base, but instead, let’s do a quick review in IEx to see what the public API looks like.
Fire up the IEx in the terminal below with iex -S mix, and key this in:
And, we should see ...
All of ...