Sha256: e98147a4aaa770f15bb800ecb9334fc6f1825235cdf149ff2942263ffb9bb798
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
class Clearance::FacebookController < ApplicationController #Js is informing that the cookie was created def index if signed_in? then redirect_to LOGGED_PATH #Evita multiples logins y hace que solo tenga sentido llamar el metodo con un nuevo cookie else #If there's no signed in user #The code arrives here if token_user(params[:token]) != nil then @user = find_fbuser(fbu.id) #The one from the DB #If the user exists if @user then sign_in_fbu(@user, params[:token], params[:expiration]) else #If theres no user with that id #Register this user register_fbu(fbu) end else #The token isn't valid closed end end end #Js is informing that the query as cleared def closed sign_out render :template => "facebook/closed" end def sign_in_fbu(myuser) sign_in(myuser) redirect_to LOGGED_PATH and return end #Here I reply the create the new user, I changed te verifications so that fbid is unique and password is optional # when fbid isn't blank def register_fbu(new_user) @user = ::User.new @user.fbid = new_user.id @user.name = new_user.name @user.email2 = new_user.email if @user.save sign_in_fbu(@user, params[:token], params[:expiration]) else render :text => "Please contact the administrator, the Facebook user couldn't be created." end end #This method return nil if theres no such user and the user if there is def find_fbuser(myfbuid) return ::User.find_by_fbid(myfbuid) end def fbtoken(mycode) access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, FB_CALLBACK_URL, FB_SECRET, mycode) return access_token = access_token_hash["access_token"] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fbdoorman-0.8.0.7 | app/controllers/clearance/facebook_controller.rb |