Skip to content

Instantly share code, notes, and snippets.

@cmaxw
Last active August 29, 2015 05:13
Show Gist options
  • Save cmaxw/6ef47281249afb3baac2 to your computer and use it in GitHub Desktop.
Save cmaxw/6ef47281249afb3baac2 to your computer and use it in GitHub Desktop.
012 RailsClips HTTP Basic Authentication
http_basic_authenticate_with name: "cmaxw", password: "railsclips"
before_filter :check_auth
def check_auth
authenticate_or_request_with_http_basic do |username,password|
resource = User.find_by_email(username)
if resource && resource.valid_password?(password)
sign_in :user, resource
end
end
end
before_filter :check_auth
def check_auth
authenticate_or_request_with_http_basic do |username,password|
users = [["cmaxw", "railsclips"], ["dhh", "rails"], ["matz", "minaswan"]]
users.include? [username, password]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment