lib/castronaut/adapters/restful_authentication/user.rb in relevance-castronaut-0.3.5 vs lib/castronaut/adapters/restful_authentication/user.rb in relevance-castronaut-0.3.6
- old
+ new
@@ -19,17 +19,28 @@
def self.secure_digest(*args)
Digest::SHA1.hexdigest(args.flatten.join('--'))
end
+ def self.find_by_login(login)
+ user = find(:first, :conditions => { :login => login })
+ return nil if user.nil?
+
+ if Castronaut.config.cas_adapter.has_key?('extra_authentication_conditions')
+ return find(:first, :conditions => ["login = ? AND #{Castronaut.config.cas_adapter['extra_authentication_conditions']}", login])
+ end
+ end
+
def self.authenticate(username, password)
if user = find_by_login(username)
if user.crypted_password == Castronaut::Adapters::RestfulAuthentication::User.digest(password, user.salt)
Castronaut::AuthenticationResult.new(username, nil)
else
+ Castronaut.config.logger.info "#{self} - Unable to authenticate username #{username} due to invalid authentication information"
Castronaut::AuthenticationResult.new(username, "Unable to authenticate the username #{username}")
end
else
+ Castronaut.config.logger.info "#{self} - Unable to authenticate username #{username} because it could not be found"
Castronaut::AuthenticationResult.new(username, "Unable to authenticate the username #{username}")
end
end
end