Skip to content

Commit

Permalink
fix authlogic issue binarylogic#267
Browse files Browse the repository at this point in the history
  • Loading branch information
ssinghi committed Jul 15, 2011
1 parent 2da24e4 commit 5b243c5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/authlogic/session/http_auth.rb
Expand Up @@ -11,10 +11,10 @@ def self.included(klass)
klass.class_eval do
extend Config
include InstanceMethods
persist :persist_by_http_auth, :if => :persist_by_http_auth?
persist :persist_by_http_auth
end
end

# Configuration for the HTTP basic auth feature of Authlogic.
module Config
# Do you want to allow your users to log in via HTTP basic auth?
Expand Down Expand Up @@ -64,15 +64,16 @@ def http_basic_auth_realm(value = nil)
end
alias_method :http_basic_auth_realm=, :http_basic_auth_realm
end

# Instance methods for the HTTP basic auth feature of authlogic.
module InstanceMethods
private
def persist_by_http_auth?
allow_http_basic_auth? && login_field && password_field
end

def persist_by_http_auth
return false unless persist_by_http_auth?
login_proc = Proc.new do |login, password|
if !login.blank? && !password.blank?
send("#{login_field}=", login)
Expand All @@ -86,10 +87,10 @@ def persist_by_http_auth
else
controller.authenticate_with_http_basic(&login_proc)
end

false
end

def allow_http_basic_auth?
self.class.allow_http_basic_auth == true
end
Expand Down

0 comments on commit 5b243c5

Please sign in to comment.