Phoenix 1.6 mix phx.gen.auth Accounts User users

Using the new Phoenix Authentication Generator

Phoenix 1.6 mix phx.gen.auth Accounts User users

Some notes of the new Phoenix Authentication Generator

Phoenix 1.6 has an authentication generator.

❯ mix phx.gen.auth Accounts User users                 
* creating priv/repo/migrations/20210901031004_create_users_auth_tables.exs
* creating lib/folkbot/accounts/user_notifier.ex
* creating lib/folkbot/accounts/user.ex
* creating lib/folkbot/accounts/user_token.ex
* creating lib/folkbot_web/controllers/user_auth.ex
* creating test/folkbot_web/controllers/user_auth_test.exs
* creating lib/folkbot_web/views/user_confirmation_view.ex
* creating lib/folkbot_web/templates/user_confirmation/new.html.heex
* creating lib/folkbot_web/templates/user_confirmation/edit.html.heex
* creating lib/folkbot_web/controllers/user_confirmation_controller.ex
* creating test/folkbot_web/controllers/user_confirmation_controller_test.exs
* creating lib/folkbot_web/templates/layout/_user_menu.html.heex
* creating lib/folkbot_web/templates/user_registration/new.html.heex
* creating lib/folkbot_web/controllers/user_registration_controller.ex
* creating test/folkbot_web/controllers/user_registration_controller_test.exs
* creating lib/folkbot_web/views/user_registration_view.ex
* creating lib/folkbot_web/views/user_reset_password_view.ex
* creating lib/folkbot_web/controllers/user_reset_password_controller.ex
* creating test/folkbot_web/controllers/user_reset_password_controller_test.exs
* creating lib/folkbot_web/templates/user_reset_password/edit.html.heex
* creating lib/folkbot_web/templates/user_reset_password/new.html.heex
* creating lib/folkbot_web/views/user_session_view.ex
* creating lib/folkbot_web/controllers/user_session_controller.ex
* creating test/folkbot_web/controllers/user_session_controller_test.exs
* creating lib/folkbot_web/templates/user_session/new.html.heex
* creating lib/folkbot_web/views/user_settings_view.ex
* creating lib/folkbot_web/templates/user_settings/edit.html.heex
* creating lib/folkbot_web/controllers/user_settings_controller.ex
* creating test/folkbot_web/controllers/user_settings_controller_test.exs
* creating lib/folkbot/accounts.ex
* injecting lib/folkbot/accounts.ex
* injecting test/folkbot/accounts_test.exs
* injecting test/support/fixtures/accounts_fixtures.ex
* injecting test/support/conn_case.ex
* injecting config/test.exs
* injecting mix.exs
* injecting lib/folkbot_web/router.ex
* injecting lib/folkbot_web/router.ex - imports
* injecting lib/folkbot_web/router.ex - plug
* injecting lib/folkbot_web/templates/layout/root.html.heex

Please re-fetch your dependencies with the following command:

    $ mix deps.get

Remember to update your repository by running migrations:

    $ mix ecto.migrate

Once you are ready, visit "/users/register"
to create your account and then access to "/dev/mailbox" to
see the account confirmation email.

Get the updates

❯ mix deps.get --all                  
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  castore 0.1.11
  certifi 2.6.1
  combine 0.10.0
  connection 1.1.0
  cowboy 2.9.0
  cowboy_telemetry 0.4.0
  cowlib 2.11.0
  db_connection 2.4.0
  decimal 2.0.0
  ecto 3.7.1
  ecto_sql 3.7.0
  esbuild 0.2.2
  file_system 0.2.10
  floki 0.31.0
  gettext 0.18.2
  hackney 1.17.4
  html_entities 0.5.2
  idna 6.1.1
  jason 1.2.2
  metrics 1.0.1
  mime 2.0.1
  mimerl 1.2.0
  parse_trans 3.3.1
  phoenix 1.6.0-rc.0
  phoenix_ecto 4.4.0
  phoenix_html 3.0.2
  phoenix_live_dashboard 0.5.0
  phoenix_live_reload 1.3.3
  phoenix_pubsub 2.0.0
  phoenix_view 1.0.0
  plug 1.12.1
  plug_cowboy 2.5.1
  plug_crypto 1.2.2
  postgrex 0.15.10
  ranch 1.8.0
  snowflake 1.0.4
  ssl_verify_fun 1.1.6
  swoosh 1.5.0
  telemetry 1.0.0
  telemetry_metrics 0.6.1
  telemetry_poller 1.0.0
  timex 3.7.6
  tzdata 1.1.0
  unicode_util_compat 0.7.0
New:
  bcrypt_elixir 2.3.0
  comeonin 5.3.2
  elixir_make 0.6.2
All dependencies are up to date

Reset



MIX_ENV=dev mix ecto.reset                                
The database for Folkbot.Repo has already been dropped
The database for Folkbot.Repo has been created

21:39:53.966 [info]  == Running 20210830022616 Folkbot.Repo.Migrations.CreateUsers.change/0 forward

21:39:53.970 [info]  execute "CREATE EXTENSION IF NOT EXISTS citext"

21:39:53.971 [info]  extension "citext" already exists, skipping

21:39:53.971 [info]  create table users

21:39:53.975 [info]  create index users_email_index

21:39:53.978 [info]  == Migrated 20210830022616 in 0.0s

21:39:53.995 [info]  == Running 20210901031004 Folkbot.Repo.Migrations.CreateUsersAuthTables.change/0 forward

21:39:53.996 [info]  create table users_tokens

21:39:53.999 [info]  create index users_tokens_user_id_index

21:39:54.000 [info]  create index users_tokens_context_token_index

21:39:54.000 [info]  == Migrated 20210901031004 in 0.0s
[debug] QUERY OK db=1.6ms queue=0.8ms idle=34.2ms
INSERT INTO "users" ("admin","editor","email","host","seller","snowflake","username","website","inserted_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10) RETURNING "id" [true, true, "[email protected]", true, true, "6831853880570023936", "niccolox", "devekko.com", ~N[2021-09-01 04:39:54], ~N[2021-09-01 04:39:54]]



❯ MIX_ENV=test mix test      
.........................................................................................................................

Finished in 0.8 seconds (0.6s async, 0.2s sync)
121 tests, 0 failures

Randomized with seed 813818
Not open today, try again tomorrow