obetReyes

obetReyes

Is there any way to set up the prebuilt auth system not using html?

is there any way to set up the prebuilt auth system without using phoenix_html? I’m trying to use the mix phx.gen.auth command, but I’m not server-side rendering the HTML. Is there another way to make it work, or are there other options?

** (Mix) mix phx.gen.auth requires phoenix_html

mix phx.gen.auth must be installed into a Phoenix 1.5 app that
contains ecto and html templates.

mix phx.new my_app
mix phx.new my_app --umbrella
mix phx.new my_app --database mysql

Apps generated with --no-ecto or --no-html are not supported.

Most Liked

arcanemachine

arcanemachine

If you just want the auto-generated files here’s what I would do:

cd /tmp
mix phx.new same_project_name_as_your_real_app
cd same_project_name_as_your_real_app
git init
git add -A
git commit -m "Some message"
mix phx.gen.auth Accounts User users

This will generate all the required files, and the console will output a list of created and modified files.

From there, you can copy the needed files over to your real project. Since there was a Git commit made before running the generators (ALWAYS make a Git commit before running the generators), you can inspect the modified (“injected”) files manually with git diff to see what modifications were made to the existing files.

Then, you can painstakingly modify the files until it works, then make a Git commit and hang onto it forever so you never have to re-visit the problem ever again.


But FYI, the auth generator assumes you are rendering the HTML. If you want a token auth system or something like that, you would need to modify the generators to get the desired functionality.

You might also be better off with something like Guardian or Pow for your auth if you are straying too far from the golden path that works best with the Phoenix auth generator.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement