roostercrab
How to use phx.gen.auth
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?
Marked As Solved
josevalim
Also Liked
benwilson512
I believe this pull request is relevant too: https://github.com/dashbitco/mix_phx_gen_auth_demo/pull/1
thojanssens1
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.
Last Post!
roostercrab
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









