Implementing Login and Logout

We made great progress in the last section. We created a module plug that loads information from the session, used this information to restrict user access and then created the functionality that allows us to finally store users in the session.

We’re almost done with our authentication feature. We need to implement both login and logout functionality, as well as change the layout to include links to those pages.

First things first. We need to add some new routes to web/router.ex:

 scope ​"​​/"​, Rumbl ​do
  pipe_through ​:browser​ ​# Use the default browser stack
 
  get ​"​​/"​, PageController, ​:index
  resources ​"​​/users"​, UserController, ​only:​ [​:index ...

Get Programming Phoenix now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.