Reputation: 15501
Im trying to authenticate based on a certain ip, if the ip is not correct access should be not allowed.
Im using in application_controller:
before_filter :authenticate
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "admin" && password == "talkmate"
end
end
What would be the correct way to add checking for IP and disallow access if the ip is not a certain value?
Upvotes: 1
Views: 219
Reputation: 230551
Check request.remote_ip
. If it's not right, render error message, or redirect to error page (or something else).
Upvotes: 3