Sha256: 7230feac3f6ae6aa30aaf9b2fc23a8695b4ec23205e5280231c9e0cea247df02
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
module AuthlogicConnect::Openid # This module is responsible for adding all of the OpenID goodness to the Authlogic::Session::Base class. module Session # Add a simple openid_identifier attribute and some validations for the field. def self.included(klass) klass.class_eval do include InstanceMethods end end module InstanceMethods include AuthlogicConnect::Openid::Process def self.included(klass) klass.class_eval do validate :validate_by_openid, :if => :authenticating_with_openid? end end # Hooks into credentials so that you can pass an :openid_identifier key. def credentials=(value) super values = value.is_a?(Array) ? value : [value] hash = values.first.is_a?(Hash) ? values.first.with_indifferent_access : nil self.openid_identifier = hash[:openid_identifier] if !hash.nil? && hash.key?(:openid_identifier) end private def auto_register? false end def complete_openid_transaction(result, openid_identifier) if result.unsuccessful? errors.add_to_base(result.message) end token = AccessToken.find_by_key(openid_identifier.normalize_identifier, :include => [:user]) self.attempted_record = token.user if token if !attempted_record if auto_register? self.attempted_record = klass.new self.attempted_record.access_tokens << OpenidToken.new(:key => openid_identifier.normalize_identifier) self.attempted_record.save else auth_session[:openid_identifier] = openid_identifier errors.add(:user, "Could not find user in our database, have you registered with your openid account?") end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authlogic-connect-0.0.4.03 | lib/authlogic_connect/openid/session.rb |