Skip to content

Instantly share code, notes, and snippets.

@acidtib
Created October 1, 2012 15:59
Show Gist options
  • Save acidtib/3812679 to your computer and use it in GitHub Desktop.
Save acidtib/3812679 to your computer and use it in GitHub Desktop.
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
def create
admins = Admin.find(current_admin.id)
user = Authentication.from_omniauth(env["omniauth.auth"], admins)
redirect_to root_url
end
@acidtib
Copy link
Author

acidtib commented Oct 1, 2012

works now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment