Michael Malone
2/22/2009 8:28:00 PM
>> Here is the entire section of code :
>> def self.authenticate(login, password)
>> user = find_by_login(login)
>> return user if user && user.authenticated?(password)
>> end
>>
>> def authenticated?(password)
>> hashed_password == encrypt(password)
>> end
>>
>> protected
>> def encrypt_new_password
>> return if password.blank?
>> self.hashed_password = encrypt(password)
>> end
>>
>> def password_required?
>> hashed_password.blank? || !password.blank?
>> end
>>
>> def encrypt(string)
>> Digest::SHA1.hexdigest(string)
>> end
>>
>
>
Um, shouldn't you be storing the result of the hash into hashed_password?
Also, if this is part of a User class (as suggested by the output
earlier) then you probably want to use @ -scoped variables, not
method-local.
def Klass
some_variable = value
end
is NOT the same as:
def Klass
def initialize
@some_variable = value
end
end
That seems the most likely problem to me. If this doesn't solve your
problem, could you post the point at which you initialise/declare your
variables?
Cheers,
Michael
=======================================================================
This email, including any attachments, is only for the intended
addressee. It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================