alanyeh
alanyeh

Reputation: 21

Differentiate the situation between facebook phone registration and email permission denied

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:)

Upvotes: 2

Views: 53

Answers (1)

Muhammad Faisal Iqbal
Muhammad Faisal Iqbal

Reputation: 1836

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

Upvotes: 0

Related Questions