Module: UsesOpenID::ClassMethods
- Defined in:
- lib/uses_openid/active_record.rb
Defined Under Namespace
Classes: OpenIDAuthenticationError
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.extended(klass) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/uses_openid/active_record.rb', line 12
def self.extended(klass)
klass.class_eval %Q{
@identity_url_class_name = '#{klass.name}IdentityURL'
has_many :identity_urls, :class_name => @identity_url_class_name, :dependent => :delete_all
}
end
|
Instance Method Details
#authenticate_with_openid(identity_url, user_args = {}) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/uses_openid/active_record.rb', line 20
def authenticate_with_openid(identity_url, user_args = {})
user_args.symbolize_keys!
email = user_args[:email]
if user = @identity_url_class_name.constantize.find_by_identity_url(identity_url).try(:user)
elsif !email.nil? and user = self.where(user_args).first
user.identity_urls.build(:identity_url => identity_url) unless user.identity_urls.where(:identity_url => identity_url).exists?
user.save(:validate => false) else
user = nil
end
user
end
|