The *self.hashedpass* action is still not in use. That is not of concern
right now. I need to encrypt the password chosen by user and save it. In
this tutorial, it sets an *attr_accessor "password"* which executes the
instance method *"password=(pass)". *The tutorial actually uses
*hashes_password
*as the attribute in table where the encrypted password is actually stored
after encryption.

During customizations I have used *password *as the column where encrypted
password shall be saved. So I created my own attr_accessor, i.e., *
passwordtext*. I have named the *password_field_tag* in my form as *
passwordtext*. But when I do so, it is not executed. Instead if I rename
the password_field_tag and the attr_accessor as* password *only, it is
executed but the stackerror comes in.

Regards
Sumit Srivastava

The power of imagination makes us infinite...


On 27 July 2012 15:28, Michael Pavling <pavl...@gmail.com> wrote:

> On 27 July 2012 10:42, sumit srivastava <sumit.theinvinci...@gmail.com>
> wrote:
> > This is the complete model. I am trying to encrypt the password.
> >>   def self.hashedpass(login, pass)
> >>     u=find(:first, :conditions=>["login = ?", login])
> >>     return nil if u.nil?
> >>     return u if User.encrypt(pass, u.salt)==u.hashed_password
> >>     nil
> >>   end
>
> You compare the hashed user input with the u.hashed_password attribute
> here...
>
> >>   def passwordtext=(pass)
> >>     #debugger
> >>     @password1=pass
> >>     self.salt = SecureRandom.hex(10) if !self.salt?
> >>     self.password = User.encrypt(@password1, self.salt)
> >>   end
>
> ...but here you're setting the "password" attribute - so is there a
> "hashed_password" attribute on the user? And if so, how is it set?
>
>
> > I am not exactly following the tutorial. I have customized things
> according to my requirements.
>
> Your requirement was to have a non-working password hashing process?!
> - as it seems that's all your customization has achieved.
> What was wrong with the tutorial that didn't work for you?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to