dwyl / auth

πŸšͺ πŸ” UX-focussed Turnkey Authentication Solution for Web Apps/APIs (Documented, Tested & Maintained)
https://authdemo.fly.dev
GNU General Public License v2.0
131 stars 9 forks source link

PR: Docs #231

Open nelsonic opened 1 year ago

nelsonic commented 1 year ago

Busy adding some docs ... πŸ‘¨β€πŸ’» ⏳

codecov[bot] commented 1 year ago

Codecov Report

Merging #231 (2bbba99) into main (6415642) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              main      #231    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           27        14    -13     
  Lines          586       190   -396     
==========================================
- Hits           586       190   -396     
Impacted Files Coverage Ξ”
lib/auth/accounts.ex 100.00% <100.00%> (ΓΈ)
lib/auth/accounts/person.ex 100.00% <100.00%> (ΓΈ)
lib/auth/accounts/person_notifier.ex 100.00% <100.00%> (ΓΈ)
lib/auth/accounts/person_token.ex 100.00% <100.00%> (ΓΈ)
lib/auth_web/controllers/error_html.ex 100.00% <100.00%> (ΓΈ)
lib/auth_web/controllers/error_json.ex 100.00% <100.00%> (ΓΈ)
lib/auth_web/controllers/page_controller.ex 100.00% <100.00%> (ΓΈ)
..._web/controllers/person_confirmation_controller.ex 100.00% <100.00%> (ΓΈ)
..._web/controllers/person_registration_controller.ex 100.00% <100.00%> (ΓΈ)
...eb/controllers/person_reset_password_controller.ex 100.00% <100.00%> (ΓΈ)
... and 29 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

nelsonic commented 1 year ago

Build failing due to:

** (ErlangError) Erlang error: {:badarg, {'aead.c', 90}, 'Unknown cipher'}
    (crypto 5.0.2) :crypto.aead_cipher_nif(:aes_256_gcm, "", 
<<164, 15, 193, 21, 34, 216, 157, 59, 173, 102, 0, 45, 69, 112, 115, 87>>, 
"admin@dwylauth.com", "AES256GCM", 16, true)
    (fields 2.8.2) lib/aes.ex:36: Fields.AES.encrypt/1

Looks like this is an issue with Fields not shipping the latest version of the AES cypher ...

https://github.com/dwyl/auth/actions/runs/3272492583/jobs/5383565807 image

BRB!

nelsonic commented 1 year ago

Oh oh ... looks like the auth Repository secrets were removed ... πŸ€·β€β™‚οΈ

https://github.com/dwyl/auth/settings/secrets/actions

auth-repo-secrets-fail

Lame! πŸ€¦β€β™‚οΈ

Re-adding them now. ⏳

nelsonic commented 1 year ago

Ref: https://github.com/dwyl/auth/blob/f6a72102fd72f99ba8c42d00083e22c2fdec917a/.github/workflows/ci.yml#L42-L52

nelsonic commented 1 year ago

Re-added all the repository secrets ...

image

nelsonic commented 1 year ago

Can of worms: https://github.com/dwyl/learn-elixir/issues/182#issuecomment-1282630190 πŸ€¦β€β™‚οΈ

nelsonic commented 1 year ago

Tests still failing on CI ... https://github.com/dwyl/auth/actions/runs/3276606455/jobs/5392858413 image

The good (? πŸ€·β€β™‚οΈ ) news is that they are also failing on my localhost ...

image

This is less interesting than working on features ... But given that it's BLOCKED progress, it's my priority for the morning ... ⏳

nelsonic commented 1 year ago

@LuchoTurtle I'm picking off each failing test at a time to fix them all. It's probably going to take a while ... βŒ› You're very welcome to join me and pair on this ... 🍐 But if you have something more interesting to work on, Stick to that. πŸ‘Œ

nelsonic commented 1 year ago

Still working on this one ... ⏳

nelsonic commented 1 year ago

Finally back to looking at this after reviewing/merging everyone else's PRs ... 🀞 Wish me luck! πŸ€

nelsonic commented 1 year ago

One to look at in the morning:

warning: undefined function live_flash/2 (expected AuthWeb.LayoutView to define such a function or for it to be imported, but none are available)
  lib/auth_web/templates/layout/live.html.heex:14
SimonLab commented 1 year ago

live_flash with LiveView 0.18 is not part of the Phoenix.Component module, see: https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html#live_flash/2

We can make sure to import this module in the view, however we'll need to change this soon with Phoenix 1.7

image

So in auth_web.ex in the view function, add import Phoenix.Component:

  def view do
    quote do
      use Phoenix.View,
        root: "lib/auth_web/templates",
        namespace: AuthWeb

      # Import convenience functions from controllers
      import Phoenix.Controller,
        only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]

     import Phoenix.Component
      # Include shared imports and aliases for views
      unquote(view_helpers())
    end
  end

I think this should resolve this issue. However I had a look at the mvp code for the view function and it looks quiet different. Switching to Phoenix 1.7 should reset/remove all the "ancient" genereated Phoenix code

https://github.com/dwyl/auth/blob/gen-erd-%23207/lib/auth_web.ex#L30-L43

nelsonic commented 1 year ago

Thanks @SimonLab πŸ‘Œ I've removed it from the layout/template as don't need the "flash" βœ‚οΈ

nelsonic commented 1 year ago

Trying to add Tailwind CSS to the Auth App but getting the following error when rendering the LiveView template:

[error] #PID<0.815.0> running AuthWeb.Endpoint (connection #PID<0.750.0>, stream id 7) terminated
Server: localhost:4000 (http)
Request: GET /groups
** (exit) an exception was raised:
    ** (KeyError) key :conn not found in: %{__changed__: %{inner_content: true}, flash: %{}, inner_content: 
%Phoenix.LiveView.Rendered{static: ["<h1 class=\"bg-gradient-to-r from-green-400 to-blue-500\">\n
Groups LiveView! Hello!\n</h1>"], dynamic: #Function<0.53126927/1 in AuthWeb.GroupsLive.render/1>, 
root: true, caller: :not_available}, live_action: nil, endpoint: AuthWeb.Endpoint, view: AuthWeb.GroupsLive, 
parent_pid: nil, root_pid: nil, router: AuthWeb.Router, assigns: #Phoenix.LiveView.Socket.AssignsNotInSocket<>, ...>}
        (auth 1.6.7) lib/auth_web/templates/layout/live.html.heex:9: anonymous fn/2 in AuthWeb.LayoutView."live.html"/1
        (phoenix_live_view 0.18.2) lib/phoenix_live_view/diff.ex:387: Phoenix.LiveView.Diff.traverse/7
        (phoenix_live_view 0.18.2) lib/phoenix_live_view/diff.ex:138: Phoenix.LiveView.Diff.render/3
        (phoenix_live_view 0.18.2) lib/phoenix_live_view/static.ex:244: Phoenix.LiveView.Static.to_rendered_content_tag/4
        (phoenix_live_view 0.18.2) lib/phoenix_live_view/static.ex:127: Phoenix.LiveView.Static.render/3
        (phoenix_live_view 0.18.2) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
        (phoenix 1.6.14) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
        (auth 1.6.7) lib/auth_web/endpoint.ex:1: AuthWeb.Endpoint.plug_builder_call/2
        (auth 1.6.7) lib/plug/debugger.ex:136: AuthWeb.Endpoint."call (overridable 3)"/2
        (auth 1.6.7) lib/auth_web/endpoint.ex:1: AuthWeb.Endpoint.call/2
        (phoenix 1.6.14) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy 2.9.0) /Users/n/code/auth/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
        (cowboy 2.9.0) /Users/n/code/auth/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
        (cowboy 2.9.0) /Users/n/code/auth/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
        (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

This is probably obvious. Will look at it after πŸ‘Ά bed time. ⏳

nelsonic commented 1 year ago

"Change mentions of @conn to @socket in live template" Thanks to: https://smartlogic.io/blog/converting-phoenix-views-to-liveviews

Works: βœ…

image

Back to documenting. ✍️

nelsonic commented 1 year ago

have the following line in LiveView file:

import Phoenix.LiveView, only: [assign_new: 3] 

Getting the following error in IDE:

(CompileError) cannot import Phoenix.LiveView.assign_new/3 
because it is undefined or private Stacktrace: β”‚ (elixir 1.14.1) 
src/elixir_import.erl:91: :elixir_import.calculate/6 β”‚ (elixir 1.14.1) 
src/elixir_import.erl:22: :elixir_import.import/4Elixir
nelsonic commented 1 year ago

https://elixirforum.com/t/assign-and-assign-new-missing-in-liveview0-18-0-what-are-we-meant-to-use-instead/50451/2 https://github.com/phoenixframework/phoenix_live_view/blob/master/CHANGELOG.md#0180-2022-09-20

Solution: replace:

import Phoenix.LiveView, only: [assign_new: 3]

With:

import Phoenix.Component, only: [assign_new: 3]

Appears to compile. πŸ‘Œ

nelsonic commented 1 year ago

On re-re-re-reading my own notes I think they are confusing. πŸ‘€ So going to re-do the group_people schema to simplify it. ⏳

nelsonic commented 1 year ago

** (ArgumentError) expected granter_id to be an assoc in put_assoc, got: :id

[error] GenServer #PID<0.711.0> terminating
** (Ecto.ConstraintError) constraint error when attempting to insert struct:

    * group_people_person_id_fkey (foreign_key_constraint)

If you would like to stop this constraint violation from raising an
exception and instead add it as an error to your changeset, please
call `foreign_key_constraint/3` on your changeset with the constraint
`:name` as an option.

The changeset has not defined any constraint.

    (ecto 3.9.1) lib/ecto/repo/schema.ex:795: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3
    (elixir 1.14.1) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (ecto 3.9.1) lib/ecto/repo/schema.ex:780: Ecto.Repo.Schema.constraints_to_errors/3
    (ecto 3.9.1) lib/ecto/repo/schema.ex:761: Ecto.Repo.Schema.apply/4
    (ecto 3.9.1) lib/ecto/repo/schema.ex:369: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
    (auth 1.6.7) lib/auth_web/live/groups_live.ex:50: AuthWeb.GroupsLive.create_group/3
    (auth 1.6.7) lib/auth_web/live/groups_live.ex:21: AuthWeb.GroupsLive.handle_event/3
    (phoenix_live_view 0.18.2) lib/phoenix_live_view/channel.ex:382: anonymous fn/3 in Phoenix.LiveView.Channel.view_handle_event/3
    (telemetry 1.1.0) /Users/n/code/auth/deps/telemetry/src/telemetry.erl:320: :telemetry.span/3
    (phoenix_live_view 0.18.2) lib/phoenix_live_view/channel.ex:216: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 4.1.1) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.1.1) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.1.1) proc_lib.erl:250: :proc_lib.wake_up/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-FyN1DUAVM0ykSwAE", event: "event", payload: %{"event" => "create", "type" => "form", "value" => "name=test+1217&desc=my+description"}, ref: "9", join_ref: "7"}
State: %{components: {%{}, %{}, 1}, join_ref: "7", serializer: Phoenix.Socket.V2.JSONSerializer, socket: #Phoenix.LiveView.Socket<id: "phx-FyN1DUAVM0ykSwAE", endpoint: AuthWeb.Endpoint, view: AuthWeb.GroupsLive, parent_pid: nil, root_pid: #PID<0.711.0>, router: AuthWeb.Router, assigns: %{__changed__: %{}, flash: %{}, live_action: nil, loggedin: true, person: %{app_id: 1, aud: "Joken", auth_provider: "github", email: "nelson@gmail.com", exp: 1698841911, givenName: "Nelson", iat: 1667304911, id: 2, iss: "Joken", jti: "totesmctoken", nbf: 1667304911, picture: "https://avatars.githubusercontent.com/u/194400?v=4", roles: "6,6", sid: 480, status: 1}}, transport_pid: #PID<0.700.0>, ...>, topic: "lv:phx-FyN1DUAVM0ykSwAE", upload_names: %{}, upload_pids: %{}}
nelsonic commented 1 year ago

Build failing because coverage is 97.4% (below the 100% requirement) ... I'm adding tests and will be back up to 100% shortly.

nelsonic commented 1 year ago

No idea why I'm seeing this error:

[error] GenServer #PID<0.997.0> terminating
** (UndefinedFunctionError) function Auth.Person.fetch/2 is undefined 
(Auth.Person does not implement the Access behaviour. 
If you are using get_in/put_in/update_in, you can specify the field to be accessed using Access.key!/1)
    (auth 1.6.7) Auth.Person.fetch(%Auth.Person{__meta__: 
#Ecto.Schema.Metadata<:loaded, "people">, id: 2, auth_provider: "github", email: "nelson@gmail.com", 
email_hash: <<97, 210, 231, 52, 197, 74, 245, 126, 6, 74, 101, 9, 145, 156, 56, 0, 132, >>, 
familyName: nil, givenName: "Nelson", locale: "en", password: nil, password_hash: nil, 
picture: "https://avatars.githubusercontent.com/u/194400?v=4", username: "nelsonic", 
username_hash: nil, status: 1, tag: nil, key_id: nil, app_id: 1, github_id: 194400, 
roles: [%Auth.Role{__meta__: #Ecto.Schema.Metadata<:loaded, "roles">, id: 6, 
desc: "Subscribes for updates e.g. newsletter or content from a specific person. 
Cannot comment until verified.", 
name: "subscriber", person_id: 1, app_id: nil, inserted_at: ~N[2022-11-01 12:16:18], 
updated_at: ~N[2022-11-01 12:16:18]}, %Auth.Role{__meta__: #Ecto.Schema.Metadata<:loaded, "roles">, 
id: 6, desc: "Subscribes for updates e.g. newsletter or content from a specific person. 
Cannot comment until verified.", name: "subscriber", person_id: 1, app_id: nil, 
inserted_at: ~N[2022-11-01 12:16:18], 
updated_at: ~N[2022-11-01 12:16:18]}], groups: [%Auth.Group{__meta__: 
#Ecto.Schema.Metadata<:loaded, "groups">, id: 7, desc: "description", kind: 1, name: 
"Simon's Group", app_id: 1, app: #Ecto.Association.NotLoaded<association :app is not loaded>, 
inserted_at: ~N[2022-11-03 10:24:32], updated_at: ~N[2022-11-03 10:24:32]}], statuses: [], 
inserted_at: ~N[2022-11-03 10:20:47], updated_at: ~N[2022-11-03 10:37:19]}, :id)
    (elixir 1.14.1) lib/access.ex:288: Access.get/3
    (auth 1.6.7) lib/auth_web/live/groups_live.ex:20: AuthWeb.GroupsLive.get_person_id/1
    (auth 1.6.7) lib/auth_web/live/groups_live.ex:32: AuthWeb.GroupsLive.create_group/3
    (auth 1.6.7) lib/auth_web/live/groups_live.ex:26: AuthWeb.GroupsLive.handle_event/3
    (phoenix_live_view 0.18.2) lib/phoenix_live_view/channel.ex:382: 
anonymous fn/3 in Phoenix.LiveView.Channel.view_handle_event/3
    (telemetry 1.1.0) /Users/n/code/auth/deps/telemetry/src/telemetry.erl:320: :telemetry.span/3
    (phoenix_live_view 0.18.2) lib/phoenix_live_view/channel.ex:216: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 4.1.1) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.1.1) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-FyQy3KDqbQjlMgIB", event: "event", 
payload: %{"event" => "create", "type" => "form", "value" => "name=amaze&desc=desc"}, 
ref: "6", join_ref: "4"}
State: %{components: {%{}, %{}, 1}, join_ref: "4", serializer: Phoenix.Socket.V2.JSONSerializer, socket: 
inserted_at: ~N[2022-11-03 10:24:32], updated_at: ~N[2022-11-03 10:24:32]}], statuses: [], 
inserted_at: ~N[2022-11-03 10:20:47], updated_at: ~N[2022-11-03 10:37:19]}}, 
transport_pid: #PID<0.988.0>, ...>, 
topic: "lv:phx-FyQy3KDqbQjlMgIB", upload_names: %{}, upload_pids: %{}}

πŸ€·β€β™‚οΈ

nelsonic commented 1 year ago

https://hexdocs.pm/elixir/Access.html

nelsonic commented 1 year ago
<ul class="w-full">
  <%= for group <- @person.groups do %>
    <li data-id={group.id} class="mt-2 flex w-full border-t border-slate-200 py-2">
      <div class="text-center text-2xl"> <%= group.name %> </div>
    </li>
  <% end %>
</ul>
nelsonic commented 1 year ago

This is what I was looking for: https://elixirschool.com/blog/til-cleaner-queries-with-ecto-map !! The ability to specify the keys of the resulting Repo.all query! πŸŽ‰

SimonLab commented 1 year ago

I think somewhere in the code you called a function on person using [], e.g. person[:id] instead of person.id. In https://hexdocs.pm/elixir/Access.html: image

Because Person is a struct the only the dot syntax can be used to access fields.

nelsonic commented 1 year ago

Yeah, I saw those docs. And scoured the code to find the instance but couldn't. The debug log from the Person query with the Repo.preload(:groups) was driving me nuts! It's fetching an ocean of data just to make a tiny query. So I'm not using it. Ecto is suuuuper inefficient. πŸ™„

nelsonic commented 1 year ago
  1) test Initialize the Auth Database Delete Everything and init again! (test branches) (Auth.InitTest)
     test/auth/init/init_test.exs:10
     ** (Ecto.ConstraintError) constraint error when attempting to delete struct:

         * people_roles_granter_id_fkey (foreign_key_constraint)

     If you would like to stop this constraint violation from raising an
     exception and instead add it as an error to your changeset, please
     call `foreign_key_constraint/3` on your changeset with the constraint
     `:name` as an option.

     The changeset has not defined any constraint.

     code: Auth.Person.delete(person)
     stacktrace:
       (ecto 3.9.1) lib/ecto/repo/schema.ex:795: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3
       (elixir 1.14.1) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
       (ecto 3.9.1) lib/ecto/repo/schema.ex:780: Ecto.Repo.Schema.constraints_to_errors/3
       (ecto 3.9.1) lib/ecto/repo/schema.ex:761: Ecto.Repo.Schema.apply/4
       (ecto 3.9.1) lib/ecto/repo/schema.ex:552: anonymous fn/11 in Ecto.Repo.Schema.do_delete/4
       test/auth/init/init_test.exs:16: (test)

Ecto ... πŸ€¦β€β™‚οΈ

nelsonic commented 1 year ago

Upgraded version of Elixir to 1.14.1 (compiled with Erlang/OTP 25)

Now getting:

  1) test Initialize the Auth Database Delete Everything and init again! (test branches) (Auth.InitTest)
     test/auth/init/init_test.exs:10
     ** (FunctionClauseError) no function clause matching in System.put_env/2

Side quest: https://github.com/dwyl/envar/issues/31

nelsonic commented 1 year ago

Continue: https://github.com/dwyl/auth/blob/gen-erd-%23207/BUILDIT.md#erd-before-adding-groups ⏳

nelsonic commented 1 year ago

https://github.com/dwyl/auth/actions/runs/3637982373/jobs/6139636711#step:4:748 image

Run erlef/setup-elixir@885971a72ed1f9240973bd92ab57af8c1aa68f24
Installing OTP OTP-24.3.4 - built on ubuntu-18.04
Installing Elixir v1.14.0
/home/runner/work/_temp/.setup-elixir/elixir/bin/mix local.rebar --force
/home/runner/work/_temp/.setup-elixir/otp/erts-12.3.2/bin/beam.smp: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
Error: The process '/home/runner/work/_temp/.setup-elixir/elixir/bin/mix' failed with exit code 12[7](https://github.com/dwyl/auth/actions/runs/3637982373/jobs/6139636711#step:4:8)

Going to re-run the tests and see if it's just a one-off error ... βŒ›

nelsonic commented 1 year ago

Build passing but CodeCov fails because below 100% ... πŸ™„

image

#progress πŸŽ‰

Only missing 28 lines of coverage and that's for the newer features #220 πŸ‘₯ So I think we can bump this back up to 100% quite quickly now. 🀞

nelsonic commented 1 year ago

Getting the following error:

ERROR 42P10 (invalid_column_reference) there is no unique or exclusion constraint matching the ON CONFLICT specification

Googling why ... πŸ”

nelsonic commented 1 year ago

Read: https://elixirschool.com/blog/til-ecto-validations-and-constraints/ https://hexdocs.pm/ecto_sql/Mix.Tasks.Ecto.Gen.Migration.html

mix ecto.gen.migration add_person_email_hash_unique_index
defmodule Auth.Repo.Migrations.AddPersonEmailHashUniqueIndex do
  use Ecto.Migration

  def change do
    create unique_index(:people, [:email_hash])
  end
end

Sadly this breaks one of our tests ... So that's what I'm fixing now. πŸ§‘β€πŸ’» ⏳

nelsonic commented 1 year ago

I've been wrestling with intermittent errors for the last two hours ... e.g:

1) test login_register_handler/2 with valid email (AuthWeb.AuthControllerTest)
     test/auth_web/controllers/auth_controller_test.exs:294
     ** (Ecto.ConstraintError) constraint error when attempting to insert struct:

         * people_pkey (unique_constraint)

     If you would like to stop this constraint violation from raising an
     exception and instead add it as an error to your changeset, please
     call `unique_constraint/3` on your changeset with the constraint
     `:name` as an option.

     The changeset defined the following constraints:

         * people_id_index (unique_constraint)

     code: post(conn, "/auth/loginregister", %{
     stacktrace:
       (ecto 3.9.1) lib/ecto/repo/schema.ex:795: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3
       (elixir 1.14.1) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
       (ecto 3.9.1) lib/ecto/repo/schema.ex:780: Ecto.Repo.Schema.constraints_to_errors/3
       (ecto 3.9.1) lib/ecto/repo/schema.ex:761: Ecto.Repo.Schema.apply/4
       (ecto 3.9.1) lib/ecto/repo/schema.ex:369: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
       (ecto 3.9.1) lib/ecto/repo/schema.ex:995: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6
       (ecto_sql 3.9.0) lib/ecto/adapters/sql.ex:1190: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
       (db_connection 2.4.2) lib/db_connection.ex:1562: DBConnection.run_transaction/4
       (ecto 3.9.1) lib/ecto/repo/schema.ex:265: Ecto.Repo.Schema.insert!/4
       (auth 1.6.7) lib/auth/person.ex:76: Auth.Person.create_person/1
       (auth 1.6.7) lib/auth_web/controllers/auth_controller.ex:272: AuthWeb.AuthController.login_register_handler/2
       (auth 1.6.7) lib/auth_web/controllers/auth_controller.ex:1: AuthWeb.AuthController.action/2
       (auth 1.6.7) lib/auth_web/controllers/auth_controller.ex:1: AuthWeb.AuthController.phoenix_controller_pipeline/2
       (phoenix 1.6.15) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
       (auth 1.6.7) lib/auth_web/endpoint.ex:1: AuthWeb.Endpoint.plug_builder_call/2
       (auth 1.6.7) lib/auth_web/endpoint.ex:1: AuthWeb.Endpoint.call/2
       (phoenix 1.6.15) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
       test/auth_web/controllers/auth_controller_test.exs:297: (test)

I think I'm ready to give up programming computers and just do wood working full time. 😒

nelsonic commented 1 year ago

Following the [probably/mostly self-inflicted] pain I've been facing with Ecto Constraint Errors in this PR ... I've come to the conclusion that I really don't want to build an Auth System from scratch. I've done it out of necessity because one didn't exist in Elixir/Phoenix when I set-out on this quest.

Even if I could build one that was an order of magnitude simpler and easier to setup, ultimately, I want to build our App, not Auth. if there was some way to clone myself and "divide and conquer" with unlimited time/resources, then we might be able to build the whole stack. But as it is I've just not been able to overcome the hurdles of building the Auth and as a result I'm holding back the team from building the features of the App.

So after much personal suffering. I'm calling it a day on this. βœ…

nelsonic commented 1 year ago

https://www.monkeyuser.com/2018/zenos-progress image

nelsonic commented 1 year ago

Taking another look at this now. ⏳ Let's see how far I can get in 2 hours. 🀞

nelsonic commented 1 year ago
mix c
The database for Auth.Repo has been dropped
09:06:28.149 [error] ERROR: ADMIN_EMAIL Environment Variable is not set
** (FunctionClauseError) no function clause matching in Auth.Person.get_person_by_email/1

    The following arguments were given to Auth.Person.get_person_by_email/1:

        # 1
        nil

    Attempted function clauses (showing 1 out of 1):

        def get_person_by_email(email) when not (email == nil)

    (auth 1.6.7) lib/auth/person.ex:261: Auth.Person.get_person_by_email/1
    (auth 1.6.7) lib/auth/init/init.ex:76: Auth.Init.create_admin/0
    (auth 1.6.7) lib/auth/init/init.ex:30: Auth.Init.main/0

This isn't great DevEx. Will try and make the onboarding a bit more gentle on the next iteration. πŸ’­

nelsonic commented 1 year ago

merging main into the gen-erd-#207 (Docs) branch will obviously fail CI. πŸ‘Ž I'm going to fix it now just so I have a βœ… before starting my re-work #207

nelsonic commented 1 year ago

scratch that. crying baby 😒 πŸ‘Ά needs my attention. so much for saturday morning focus time. βŒ›

nelsonic commented 1 year ago

Managed to settle the munchkin: πŸ‘Ό 😴

image

Let's try some focus time again. πŸ§‘β€πŸ’» ⏳ 🀞

nelsonic commented 1 year ago

Dude, the mix phx.gen.auth generator creates a lot of boilerplate code that we have no intention of using ... πŸ™„