Rails, Devise and Basic HTTP Auth, Oh My!
Here's how to get basic http auth working in rails with devise:
devise.rb
config.http_authenticatable = true
application_controller.rb
before_filter :authenticate
def authenticate
authenticate_or_request_with_http_basic do |email, password|
user = User.where(email: email).first
!user.nil? && user.valid_password?(password)
end
warden.custom_failure! if performed?
end
Written by Sean
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#