gothinkster / elixir-phoenix-realworld-example-app

Exemplary real world application built with Elixir + Phoenix
https://realworld.io
MIT License
892 stars 140 forks source link

Redundant and confusing code in UserController#current_user #24

Open mtarnovan opened 6 years ago

mtarnovan commented 6 years ago

I believe https://github.com/gothinkster/elixir-phoenix-realworld-example-app/blob/master/lib/real_world_web/controllers/user_controller.ex#L29-L35 is redundant and confusing. There is no need to check user for nil and render 404.json, as Guardian already has an error handler which will be invoked when trying to access UserController#current_user without being authenticated.

lbighetti commented 5 years ago

@mtarnovan I absolutely agree. Can you send a PR with the suggestion? I'll merge it in ❤️

lbighetti commented 5 years ago

(sorry for the delay by the way, my first baby boy was born in August I have been away for a while)