Sha256: 5bd2ea9c9c5e3c2e46df4dce7a27098e71d328b8e5a9aaac90e381cd9e63adf5
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com # All files in this distribution are subject to the terms of the Ruby license. require 'tmpdir' require 'openid' module Ramaze # This is called Identity to avoid collisions with the original openid.rb module IdentityHelper def self.included(klass) klass.send(:helper, :flash) end def openid_login_form %{ <form method="GET" action="#{R(self, :openid_begin)}"> Identity URL: <input type="text" name="url" /> <input type="submit" /> </form> } end def openid_begin url = request['url'] redirect_referrer if url.nil? or url.empty? session[:openid_entry] = request.referrer openid_request = openid_consumer.begin(url) case openid_request.status when OpenID::FAILURE flash[:error] = "OpenID - Unable to find openid server for `#{url}'" redirect_referrer when OpenID::SUCCESS root = "http://#{request.http_host}/" return_to = root[0..-2] + R(self, :openid_complete) redirect_url = openid_request.redirect_url(root, return_to) redirect(redirect_url) end end def openid_complete openid_response = openid_consumer.complete(request.params) case openid_response.status when OpenID::FAILURE flash[:error] = 'OpenID - Verification failed.' when OpenID::SUCCESS session[:openid_identity] = openid_response.identity_url flash[:success] = 'OpenID - Verification done.' end session.delete(:_openid_consumer_service) redirect session[:openid_entry] end private def openid_consumer OpenID::Consumer.new(session, Ramaze::Global.openid_store) end end end openid_store_file = File.join(Dir.tmpdir, 'openid-store') Ramaze::Global.openid_store ||= OpenID::FilesystemStore.new(openid_store_file)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ramaze-0.0.9 | lib/ramaze/helper/identity.rb |
ramaze-0.1.0 | lib/ramaze/helper/identity.rb |
ramaze-0.1.1 | lib/ramaze/helper/identity.rb |