-
Notifications
You must be signed in to change notification settings - Fork 14
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
[PR] Adding auth #56
[PR] Adding auth #56
Conversation
This should be done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LuchoTurtle the "Todo" in #37 was to "lift-and-shift" from: dwyl/phoenix-chat-example#120 ...
That added optional auth
. i.e. people could still try the app without authenticating.
Adding |> validate_required([:person_email, :text])
to the item
changeset means that it's no longer optional. unless you are capturing their email
address. But then why are we complicating this? 🤷♂️
Co-authored-by: Nelson <[email protected]>
@nelsonic I knew that an |
We don't want to store email addresses in a random app tutorial app [or any other non-auth app for that matter]. A This isn't a question of "good faith" ... As much as I want to just ignore this, and get back to my work, I cannot. Our Please make your own life a lot simpler and try not over-think it. 🙏 |
The I'll change it. |
PR is assigned to me. I am reviewing now. I will be leaving comments and making the relevant updates on |
My reading of the This will impact the next person's ability to run the finished project on their |
Created Now tidying up these warnings: mix test
warning: variable "item" is unused (if the variable is not meant to be used, prefix it with an underscore)
test/app_web/controllers/item_controller_test.exs:85: AppWeb.ItemControllerTest."test clear completed clears the completed items"/1
warning: variable "items" is unused (if the variable is not meant to be used, prefix it with an underscore)
test/app_web/controllers/item_controller_test.exs:91: AppWeb.ItemControllerTest."test clear completed clears the completed items"/1
warning: variable "item" is unused (if the variable is not meant to be used, prefix it with an underscore)
test/app_web/controllers/item_controller_test.exs:98: AppWeb.ItemControllerTest."test clear completed clears the completed items in public (person_id=0)"/1
warning: variable "items" is unused (if the variable is not meant to be used, prefix it with an underscore)
test/app_web/controllers/item_controller_test.exs:104: AppWeb.ItemControllerTest."test clear completed clears the completed items in public (person_id=0)"/1
warning: key :givenName will be overridden in map
test/app_web/controllers/item_controller_test.exs:149
..........warning: module attribute @completed_attrs was set but never used
test/app_web/controllers/item_controller_test.exs:9
........................
Finished in 0.7 seconds (0.6s async, 0.1s sync)
34 tests, 0 failures
Randomized with seed 76640 |
OK no more warnings: mix c
..................................
Finished in 0.6 seconds (0.5s async, 0.07s sync)
34 tests, 0 failures
Randomized with seed 910810
----------------
COV FILE LINES RELEVANT MISSED
100.0% lib/app/todo.ex 112 7 0
100.0% lib/app/todo/item.ex 19 2 0
100.0% lib/app_web/controllers/auth_controller. 14 2 0
100.0% lib/app_web/controllers/error_html.ex 19 1 0
100.0% lib/app_web/controllers/error_json.ex 15 1 0
97.8% lib/app_web/controllers/item_controller. 123 45 1
100.0% lib/app_web/controllers/item_html.ex 41 13 0
0.0% lib/app_web/gettext.ex 24 0 0
100.0% lib/app_web/router.ex 35 8 0
[TOTAL] 98.7%
----------------
Generating report... But still missing that crucial last line of code coverage to reach |
This fix might entail tinkering with the endpoints at |
Then I started re-reading case Map.has_key?(conn.assigns, :person) do
false ->
items = Todo.list_items()
changeset = Todo.change_item(item)
render(conn, "index.html",
items: items,
changeset: changeset,
editing: item,
filter: Map.get(params, "filter", "all")
)
true ->
person_id = Map.get(conn.assigns.person, :id)
items = Todo.list_items(person_id)
changeset =
render(conn, "index.html",
items: Todo.list_items(person_id),
changeset: Todo.change_item(item),
editing: item,
filter: Map.get(params, "filter", "all")
)
end DRYed to: render(conn, "index.html",
items: Todo.list_items(Useful.get_in_default(conn, [:assigns, :person, :id], 0)),
changeset: Todo.change_item(item),
editing: item,
filter: Map.get(params, "filter", "all")
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LuchoTurtle great work. Thanks. 🎉
This PR adds authentication which allows people to filter for
items
they created.Closes: