Last active
February 21, 2017 00:53
-
-
Save mfifth/dd8ac957f9d8b4bfe5405ca44c76c76d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.from_omniauth(auth) | |
| @user = User.find(self.id) | |
| unless User.where(provider: auth.provider, uid: auth.uid).first | |
| @user.provider = auth.provider | |
| @user.uid = auth.uid | |
| @user.save | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
| def facebook | |
| @user = User.from_omniauth(request.env["omniauth.auth"]) | |
| if @user.persisted? | |
| sign_in_and_redirect @user, notice: "You have successfully connected Facebook." | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment