Rails Login Only Password

What is the best way to password protect a view? I already generate a password, but I do not want the username and password to be logged in, just the password. I have a password that is currently stored as an attribute in the File class, and used this:

before_filter :restrict, :only => :show    

authenticate_or_request_with_http_basic do |password|
  password == @file.password
end

However, it still asks for the username from the user and is not logging in correctly because the username is missing. Is there a way to use this method, and only the request will tell only the password? If not the best way to do this?

+5
source share
2 answers

authenticate_or_request_with_http_basic HTTP Basic Auth, . ,

before_filter :restrict, :only=>:show

def restrict(password)
  render :status=>401, :text=>"Unathorized" unless password == @file.password
end 
+3

(onCreate) , ?

- :

if (password.equals(password)){
contiue activity
}else{
//return to previous tread
finish()
}
-4

All Articles