andrew v
2010-May-28 11:11 UTC
reset restful authentication user password from rails console
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 :). Any help in this regard will be appreciated. Regards, 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-May-28 12:37 UTC
Re: reset restful authentication user password from rails console
On May 28, 12:11 pm, andrew v <andrew....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
andrew v
2010-May-28 14:49 UTC
Re: Re: reset restful authentication user password from rails console
On Fri, May 28, 2010 at 6:07 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On May 28, 12:11 pm, andrew v <andrew....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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: "admin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", 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>> quitEventhough 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-May-28 15:19 UTC
Re: reset restful authentication user password from rails console
On May 28, 3:49 pm, andrew v <andrew....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, May 28, 2010 at 6:07 PM, Frederick Cheung < > 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: >the password needs to be hashed with the salt. However you don''t to know any of that - normally you''ll have a before_save :encrypt_password or something like that: if you set password & password_confirmation then restful auth will do the hashing for you when you save the record Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Josh Cheek
2010-May-28 15:23 UTC
Re: Re: reset restful authentication user password from rails console
On Fri, May 28, 2010 at 9:49 AM, andrew v <andrew.var-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Fri, May 28, 2010 at 6:07 PM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> On May 28, 12:11 pm, andrew v <andrew....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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: "admin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-May-28 18:47 UTC
Re: reset restful authentication user password from rails co
andrew v wrote:> Hi, > > I have implemented restful authentication plugin in my rails > application.[...] Great. Now take it out and put in Authlogic or something. restful_authentication relies on unmaintainable generated code, and no Rails developer should even consider using it now that better alternatives exist. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
andrew v
2010-May-29 04:25 UTC
Re: Re: reset restful authentication user password from rails console
Hi Fred, You got it spot on! It finally worked. I was barking up the wrong tree. Thanks a lot for your help mate! Now I''ve got to figure out the rest of the functionality for my application. But at least now I know where to seek help :) Cheers, Andrew On Fri, May 28, 2010 at 8:53 PM, Josh Cheek <josh.cheek-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, May 28, 2010 at 9:49 AM, andrew v <andrew.var-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> On Fri, May 28, 2010 at 6:07 PM, Frederick Cheung < >> frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> >>> >>> On May 28, 12:11 pm, andrew v <andrew....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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: "admin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> . >>> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
andrew v
2010-May-29 04:29 UTC
Re: Re: reset restful authentication user password from rails co
Hi Marnen, Apparently I was looking in the wrong places or was reading dated RoR stuff ''cause wherever I looked RA was the overwhelming favorite for authentication. But considering the problems I''ve had thus far with RA, I''ll surely look into authlogic for my next project. If I run into any problems, I''m sure I can count on your help :) Thanks and Regards, Andrew On Sat, May 29, 2010 at 12:17 AM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> andrew v wrote: > > Hi, > > > > I have implemented restful authentication plugin in my rails > > application. > [...] > > Great. Now take it out and put in Authlogic or something. > restful_authentication relies on unmaintainable generated code, and no > Rails developer should even consider using it now that better > alternatives exist. > > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-May-29 04:59 UTC
Re: Re: reset restful authentication user password from rail
andrew v wrote:> Hi Marnen, > > Apparently I was looking in the wrong places or was reading dated RoR > stuff > ''cause wherever I looked RA was the overwhelming favorite for > authentication.It used to be. It''s pretty easy to use, and its API isn''t bad (though not as slick as Authlogic). The problem is all the crap it puts in your User model, mixed in with the code you actually wanted to have in there. Authlogic is much more self-contained. (I''ve heard good things about Devise and some others too, but never tried them.)> But considering the problems I''ve had thus far with RA, > I''ll > surely look into authlogic for my next project. If I run into any > problems, > I''m sure I can count on your help :)I''ll be what help I can.> > Thanks and Regards, > Andrew > > On Sat, May 29, 2010 at 12:17 AM, Marnen Laibow-KoserBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.