On Fri, May 28, 2010 at 9:49 AM, andrew v <andrew....@gmail.com> wrote:

>
>
> On Fri, May 28, 2010 at 6:07 PM, Frederick Cheung <
> frederick.che...@gmail.com> wrote:
>
>>
>>
>> On May 28, 12:11 pm, andrew v <andrew....@gmail.com> wrote:
>> > Hi,
>> >
>> > I have implemented restful authentication plugin in my rails
>> application.
>> > It's a barebones implementation without activation, forget password
>> features
>> > ...etc. I was wondering if it is possible to reset a User's password
>> from
>> > the rails console? As things stand now, there is no other way to reset
>> their
>> > passwords :).
>> >
>>
>> Haven't used restful auth in a long long time, but you should be able
>> to do exactly what a controller would do when setting a password:
>>
>> user.password = 'imAdummy'
>> user.password_confirmation = 'imAdummy'
>> user.save!
>>
>> Fred
>>
>> --Hi Fred,
>>
>
> The users table has crypted_password, and salt columns which is giving me
> problems when I try to reset password from the console.After reading the
> documentation for restful authentication, it appears that the I need to
> store the hashed password in crypted_password field. Therefore, I approached
> the problem as follows:
>
> Loading development environment (Rails 2.3.5)
> >> require 'digest/sha1'
> => []
> >> user=User.find_by_login('admin')
> => #<User id: 2, login: "admin", name: "", email: "ad...@gmail.com",
> crypted_pas
> sword: "b6fe78bbb5f6f1b2c7e6061a2e2a80bbdc538194", salt:
> "502d171c369fac51309dd9
> 1aea49c9cabe9eed20", created_at: "2010-05-17 08:54:44", updated_at:
> "2010-05-17
> 09:21:30", remember_token: nil, remember_token_expires_at: nil, admin:
> true>
> >> user.crypted_password=Digest::SHA1.hexdigest("kramer")
> => "060938ead8dbea8fece5711eb89b8e097d79e8d5"
> >> user.salt
> => "502d171c369fac51309dd91aea49c9cabe9eed20"
> >> user.save
> => true
> >> quit
>
> Eventhough everything appears to go smoothly and also user.save returns
> "true", I am unable to login as admin. Have I overlooked something?
>
> Thanks in advance for your help
>
> Andrew
>
>
>>  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-t...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>>
>  --
> 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-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>


...just do what he said and it should work fine.

(I say this, b/c I just opened up my app and tried it, and it worked)

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to