For anyone who is reading this thread in the future, I've made an edit for future reference so when you go back to it, you see the corrections made below.
model/user.rb
Change the 3rd block of code inside def self.authenticate(creds) that authenticates to
if !user.nil? and user.password == password && !flash[:fblogout] #user/pass login
return user
elsif $fb_goforth === true #facebook login
return user
else
return false
end
controller/users.rb
def logout
user_logout
session.clear
$fbprofile = nil
flash[:fblogout] = 'yes'
redirect(Main.r(:index))
end
controller/users.rb (again!)
This leaves a question, what is $fbprofile for, if it's obvious from reading above what flash[:fblogout] is for, and $fbprofile hasn't appeared anywhere yet.
You're supposed to use $fbprofile inside controllers/main.rb inside the before_all block/method, for whatever ruby gem you are using to authenticate your user with Login with Facebook.
$fbprofile is a hash that contains the information of the authenticated facebook user, with their name, age, and location.
This also leaves another question. When do I use $fb_goforth ?
$fb_goforth is used to say that someone has just successfully logged into their user account of your website, by authenticating with their Facebook account.
This is what tells the self.authenticate method that you are logged in, so it can fetch your account as the user object. Yes this interegates with Ramaze's User helper.
If you're using the Javascript SDK you should login users into their user account once they have authenticated with Facebook. The controller looks like this.
def fb_login
# ... stuff here ...
if @lookup then $fb_goforth = true; else $fb_goforth = false; end
# ... stuff here ...
end
^^ Figure out that part of the code yourself. ;) ^^