Skip to content

Instantly share code, notes, and snippets.

View maxgillett's full-sized avatar

Max Gillett maxgillett

View GitHub Profile
<link rel="stylesheet"
href="http://yandex.st/highlightjs/6.1/styles/zenburn.min.css">
<style>
code {
font-family: monospace;
overflow: auto;
}
</style>
<script src='http://yandex.st/highlightjs/6.1/highlight.min.js'></script>
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
class AuthenticationsController < ApplicationController
def create
auth = request.env['omniauth.auth']
logger.debug "Auth variable: #{auth.inspect}"
# Try to find authentication first
authentication = Authentication.find_by_provider_and_uid(auth['provider'], auth['uid'])
unless current_user
# Request a new 60 day token using the current 2 hour token obtained from fb
class Authentication < ActiveRecord::Base
attr_accessible :provider, :token, :uid, :user_id
belongs_to :user
end
<div id="fb-root"></div> <!-- Needed for facebook to function properly. See facebook sdk for more info. -->
<div id="results"></div>
<p id="connect">
<a class="signin" href="#">Signin</a>
<a class="signout" href="#">Signout</a>
</p>
<script type="text/javascript">