ueberauth / ueberauth_facebook

Facebook OAuth2 Strategy for Überauth.
MIT License
77 stars 64 forks source link

nil given for :email. Comparison with nil is forbidden as it is unsafe. Instead write a query with is_nil/1, for example: is_nil(s.email) #67

Closed UsamaHaide0786 closed 2 years ago

yordis commented 2 years ago

@UsamaHaide0786 sorry for the situation you are having.

In the future, try to open one issue in the appropriate provider repository that you are having the issue with. It felt like spam opening the same messages 3 times.

Do you have any example repository that we can work with? What have you done so far to debug the situation? Do you have the basic skills to debug the situation and fix the issue yourself with our help?

UsamaHaide0786 commented 2 years ago

Thanks for replying here is the repository I'm working on @yordis https://github.com/UsamaHaide0786/examle_chatapp

UsamaHaide0786 commented 2 years ago

@yordis I'm not experienced enough to solve it by myself any help will be appreciated Thank you

yordis commented 2 years ago

What is the exact issue you are see in your console, or somewhere?

UsamaHaide0786 commented 2 years ago

@yordis


[error] #PID<0.732.0> running FchatappWeb.Endpoint (connection #PID<0.701.0>, stream id 13) terminated
Server: localhost:4001 (https)
Request: GET /auth/facebook/callback?code=AQCKKe6OX7S2J3Mtrqvg31f-TPHcfsRA-a84p04zydlCG-2agwIcnKObcisT3k2N1AvkV5jGlzcjl-M0dG_5yjYYWca5jiZ_S25NzWxbxZZE0JtHKiCj8en8p-DWPgrjdHxGHkuA1OFWd2kEQz1OIDziVtvhghsp_jXBLaHJZML5B6wLCAlTyEDmLejdzUDU-dK_YAfRRFdJTKhgvOfAN6lVG3vCv8DkRlbs6c0cfdvk9fjP2ywr8ZP7bFY8Fl5MJVi2KpRykiIvRL0Owc4Ru3dZp5n000R-q8A8sxmBPUWwIq-h30wTkt3xfKFWg6q7LQBWQ_EqtlislDxswb7sNQLQj1v7AFMNHcFWyKONBBYVpI-ORh9mo31MrhqF7Gej_ZA&state=GlQGjsoRVjlMpkRWfivJs9pR
** (exit) an exception was raised:
    ** (ArgumentError) nil given for :email. Comparison with nil is forbidden as it is unsafe. Instead write a query with is_nil/1, for example: is_nil(s.email)
        (ecto 3.7.1) lib/ecto/query/builder/filter.ex:161: Ecto.Query.Builder.Filter.kw!/7
        (ecto 3.7.1) lib/ecto/query/builder/filter.ex:154: Ecto.Query.Builder.Filter.kw!/3
        (ecto 3.7.1) lib/ecto/query/builder/filter.ex:120: Ecto.Query.Builder.Filter.filter!/6
        (ecto 3.7.1) lib/ecto/query/builder/filter.ex:148: Ecto.Query.Builder.Filter.filter!/7
        (ecto 3.7.1) lib/ecto/repo/queryable.ex:72: Ecto.Repo.Queryable.get_by/4
        (fchatapp 0.1.0) lib/fchatapp_web/controllers/auth_controller.ex:36: FchatappWeb.AuthController.callback/2
        (fchatapp 0.1.0) lib/fchatapp_web/controllers/auth_controller.ex:1: FchatappWeb.AuthController.action/2
        (fchatapp 0.1.0) lib/fchatapp_web/controllers/auth_controller.ex:1: FchatappWeb.AuthController.phoenix_controller_pipeline/2
        (phoenix 1.5.13) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2
        (fchatapp 0.1.0) lib/fchatapp_web/endpoint.ex:1: FchatappWeb.Endpoint.plug_builder_call/2
        (fchatapp 0.1.0) lib/plug/debugger.ex:136: FchatappWeb.Endpoint."call (overridable 3)"/2
        (fchatapp 0.1.0) lib/fchatapp_web/endpoint.ex:1: FchatappWeb.Endpoint.call/2
        (phoenix 1.5.13) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy 2.9.0) /Users/usamahaider-invozone/fchatapp/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
        (cowboy 2.9.0) /Users/usamahaider-invozone/fchatapp/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
        (cowboy 2.9.0) /Users/usamahaider-invozone/fchatapp/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
        (stdlib 3.14.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
yordis commented 2 years ago

This is not an issue with Ueberauth, neither it is an issue with Ecto, but your code:

https://github.com/UsamaHaide0786/examle_chatapp/blob/d8ffb90cc73362db423b1cd601ee4edeabe61d54/lib/fchatapp_web/controllers/auth_controller.ex#L36

When auth.info.email is nil then it will fail. Check for nil values or don't use get_by or something else.

UsamaHaide0786 commented 2 years ago

@yordis Thank you very much