This file contains 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
<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> |
This file contains 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 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 |
This file contains 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 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 |
This file contains 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 Authentication < ActiveRecord::Base | |
attr_accessible :provider, :token, :uid, :user_id | |
belongs_to :user | |
end |
This file contains 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
<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"> |
NewerOlder