2

I'm using omniauth-facebook gem & devise gem to accomplish the facebook login on my site (Rails website). When using facebook login, I'll request email field and save it in my database. Everything works fine so far. But I found there are two situations I can't receive email fields.

  1. When user register facebook by phone and try to login my site with facebook, the returned email field would be nil.
  2. When user register facebook by email, but decline the email permission during authorization, the returned email field would be nil.

I can't differentiate these two situations, because the email are all nil. Does anyone meet the same problem and get a nice solution or workaround?

Much appreciated:)

alanyeh
  • 21
  • 6
  • 1
    Why would you need to differentiate between them? In both cases the user doesn't want to give their email to you – WizKid Apr 02 '18 at 05:33
  • 1
    @WizKid I don't think so. Users who register facebook with phone doesn't mean they don't want to give the email. In this situation I can remind them that they don't have any facebook email at present. – alanyeh Apr 02 '18 at 05:58

1 Answers1

0

Look at this requesting-and-revoking

It has call

GET /{user-id}/permissions

And in response

{
  "data": [
    {
      "permission": "public_profile",
      "status": "granted"
    },
    {
      "permission": "publish_actions",
      "status": "granted"
    },
    {
      "permission": "user_friends",
      "status": "declined"
    }
  ]
}

From here you can easily differentiate that whether its email permission declined or not.

If email permission granted & no email exist in response data than its surely a case of registration through phone

Muhammad Faisal Iqbal
  • 1,796
  • 2
  • 20
  • 43