Hi, I’m trying to figure out how to use the new phx.gen.auth generator and I have followed through with the commands here:
But I don’t see what I am supposed to do after that. I can create accounts and be logged in, but how do I set pages so that they are behind the authentication wall?
I’ve even looked at Jose’s demo app here:
but I can’t see how it isn’t just a regular Phoenix app named demo?
As Jose said, you can find the plug
:require_authenticated_user being used in the router file, protecting routes against unauthenticated users. You can find the code of that plug in the controllers, in the
(your schema name)Auth module.
What I personally did to see clearly all the code being generated, is creating two new Phoenix projects. On one of them I run the generator. Then I compare the code of both projects with my diff tool, study, and copy code into my project.
I feel quite silly that I missed that, thanks boss.
For anybody else having the same trouble, the auth branch in the demo is the one with the code that shows you how it works.