Reputation: 37
I've got a very basic website i'm building for a friend, he requires a 'password' on a page and if the user isn't successful he wants it to redirect to a contact me page.
I've currently got this...
before_filter :authenticate
def authenticate
authenticate_or_request_with_http_basic do |username, password|
if(username == "" && password == "***")
true
else
redirect_to '/pages/contact'
end
end
end
however it redirects to the contact page upon clicking on the link... how can I get it to prompt for the password?
Upvotes: 1
Views: 586
Reputation: 91
Could you try this:
before_filter :authenticate
def authenticate
authenticate_or_request_with_http_basic do |username, password|
redirect_to '/pages/contact' unless (username == "" && password == "***")
end
end
Note:
Another suggestion, from your above code, I would like to suggest you to take a look this discussion: redirect_to is not return in Rails in order to avoid unexpected error.
Upvotes: 1