Skip to content

Instantly share code, notes, and snippets.

@benburkert
Created August 6, 2008 01:28
Show Gist options
  • Save benburkert/4148 to your computer and use it in GitHub Desktop.
Save benburkert/4148 to your computer and use it in GitHub Desktop.
class Sessions < Application
def create
session.authenticate! #authenticates the user by username/password OR openid, raises an Unauthenticated if the user cannot be authenticated
redirect(url(:home))
end
end
class Session
def authenticate!
#OpenID authentication
if @controller.params[:openid_url] #The user is initiating authentication, they must be redirected to the their provider
checkid_request = openid_consumer.begin(openid_url) #some openid gem that does the heavy lifting
throw(:halt, c.redirect(checkid_request.redirect_url(c.request.protocol + c.request.host, c.absolute_url(:login)))) #halt the response and just redirect them
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment