So I have a very basic static pages rails app, and I want to create a number of usernames and passwords for people to access these static pages. Naturally, the rails api has the http_basic_atenticate, but how are you supposed to have more than one user?
To be clear, I want to only use http_basic for more than one user. How to go about this?
Eg; user1 has password1, user2 has password2, user3 has password3, and so forth?
class StaticController < ApplicationController
http_basic_authenticate_with :name => "user", :password => "password"
def home
end
def content
end
end
Simple solution:
h = Hash[user1: "Password1", user2: "Password2"]
authenticate_or_request_with_http_basic do |id, password|
if h.has_key?(id.to_sym)
password == h[id.to_sym]
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With