Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

76 Separate Authentication & Registration Views #79

Merged
merged 8 commits into from
Jul 17, 2024

Conversation

type1fool
Copy link
Collaborator

@type1fool type1fool commented Jul 14, 2024

Overview

Resolves #76

The default Phoenix auth generator established a pattern of creating one LiveView for registration and a second for authentication. This is common practice in web apps.

To follow this pattern and to make the generated code a bit clearer, this PR splits up registration and authentication into two LiveViews.

Changes

  • Fixed app name in the generator
    • Use Mix project name instead of dirname
  • Extracted RegistrationLive from AuthenticationLive
  • Added PasskeyComponents
  • Updated router and navbar component
  • Updated tests
  • Bumped version to 0.8.0

Tests

This was tested on a local dev machine using a fresh Phoenix app in webauthn_components_demo. See PR 20.

🟡 Note that when using a local path dependency in Mix, the JS hooks have to be imported from the webauthn_components/priv/static directory, wherever it may be. This is a manual step for now.

▶ mix wac.install

▶ MIX_ENV=test mix do ecto.reset, test
The database for Demo.Repo has been dropped
The database for Demo.Repo has been created

16:56:48.544 [info] == Running 20240714215619 Demo.Repo.Migrations.CreateUsers.change/0 forward

16:56:48.544 [info] create table users

16:56:48.546 [info] create index users_email_index

16:56:48.547 [info] == Migrated 20240714215619 in 0.0s

16:56:48.557 [info] == Running 20240714215620 Demo.Repo.Migrations.CreateUserKeys.change/0 forward

16:56:48.557 [info] create table user_keys

16:56:48.559 [info] create index user_keys_user_id_index

16:56:48.560 [info] create index user_keys_key_id_index

16:56:48.560 [info] create index user_keys_user_id_label_index

16:56:48.561 [info] == Migrated 20240714215620 in 0.0s

16:56:48.562 [info] == Running 20240714215621 Demo.Repo.Migrations.CreateUserTokens.change/0 forward

16:56:48.562 [info] create table user_tokens

16:56:48.563 [info] create index user_tokens_user_id_index

16:56:48.563 [info] == Migrated 20240714215621 in 0.0s
Running ExUnit with seed: 642952, max_cases: 20

.....................
Finished in 0.2 seconds (0.2s async, 0.08s sync)
21 tests, 0 failures

Collaborators

  1. @type1fool

@type1fool type1fool added the enhancement New feature or request label Jul 14, 2024
@type1fool type1fool self-assigned this Jul 14, 2024
@type1fool type1fool marked this pull request as ready for review July 14, 2024 22:06
@type1fool
Copy link
Collaborator Author

@peaceful-james @MitchellJeppson I would appreciate your feedback on this one if you have time. I plan on leaving it open for a few days.

Copy link
Contributor

@peaceful-james peaceful-james left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@type1fool type1fool merged commit ff95d04 into main Jul 17, 2024
1 check passed
@type1fool type1fool deleted the 76-separate-authentication-registration-views branch July 17, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REQUEST] - Separate LiveViews for "register" and "login", just like phx.gen.auth
2 participants