-1

I'm new to ROR and trying to build an invite based auth. Currently, I'm using Omniauth-facebook to have login using fb on my site. However, I want the users to have a custom url like - "www.mysite.com/invite/" which they can share to drive signup. I would also track these referrals so that I could incentivise users to drive such logins. I'm absolutely clueless about how to proceed and any starting pointers would be great.

One way could be to have a route for '/invite/:invite_code' and before the "/auth/facebook" is triggered I could read the invite code and increment the counter but then how do I check if the "/auth/facebook" was called from the invite page only. Does this sound correct? Or are there better solutions out there?

Thanks a lot!

Prakhar
  • 3,486
  • 17
  • 44
  • 61

1 Answers1

0

You would make a POST to auth/facebook having more or less this code in you OmniAuth callbacks controller:

def facebook
  Invitation.increment if request.env['omniauth.params'][:from_invitation_page]
  # OR
  # Invitation.increment if request.env['omniauth.origin'].match /your_invitation_url/

See that:

request.env['omniauth.origin']

is set automatically, while:

request.env['omniauth.params']

is set rendering a link like:

omniauth_authorize_path(:user, :facebook, var: 'value', var2: 'value2' )

Source

Community
  • 1
  • 1
sites
  • 21,417
  • 17
  • 87
  • 146