Created
October 1, 2012 15:59
-
-
Save acidtib/3812679 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,admins) | |
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |authentication| | |
authentication.admin_id = admins.id | |
authentication.provider = auth.provider | |
authentication.uid = auth.uid | |
authentication.oauth_token = auth.credentials.token | |
authentication.oauth_expires_at = Time.at(auth.credentials.expires_at) | |
authentication.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
def create | |
admins = Admin.find(current_admin.id) | |
user = Authentication.from_omniauth(env["omniauth.auth"], admins) | |
redirect_to root_url | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works now