Search code examples
ruby-on-railstokenomniauth

store website invite token parameter during FB login


A user can share our website url with his invite token as www.weburl.com/invite_token. Then a user can signup using his FB account. After logging in am loosing the invite token because of FB login.

How do I propagate or save this invite_token during auth/facebook/callback to my login page.

Gems used in my app are:

gem 'omniauth-facebook'
gem 'koala'

Solution

  • Have you tried HTML5 LocalStorage. So here a quick solution:

    User supplied www.weburl.com/123123123 to another user. Then Second user clicks on the link and lands on your homepage. Now you need to save the token in the HTML5 Storage.

    Something like this:

    window.localStorage.setItem("invite_token", '123123123');
    

    Now Your user will use the Facebook account to login. After user logged in, and landed in the Dashboard or UserLanding Page ( I assume ) you simply call the

     var foo = window.localStorage.getItem("invite_token");
       // Now Save foo with Ajax or something like that
    

    Save it, then remove it:

     window.localStorage.removeItem("invite_token");  
    

    Done!