search for: hash_password

Displaying 20 results from an estimated 22 matches for "hash_password".

2006 Feb 15
8
Agile book - getting confusing error
...uot;=>"craig", "password"=>"test"}} OK... My user.rb includes... require "digest/sha1" class User < ActiveRecord::Base attr_accessor :password attr_accessible :login, :password, :name def before_create self.hashed_password = User.hash_password(self.password) end private def self.hash_password(password) Digest::SHA1.hexdigest(password) end end Where am I going wrong? Craig
2006 Apr 03
7
Getters and setters problem?
..." class User < ActiveRecord::Base attr_accessor :password, :login attr_accessible :password, :name, :login, :email validates_confirmation_of :password validates_presence_of :name, :login, :password, :email validates_uniqueness_of :login def before_create self.password=User.hash_password(self.password) self.login="blaat" end def after_create @password=nil end private def self.hash_password(password) Digest::SHA1.hexdigest(password) end end Thanks in advance, Wijnand -- OpenBSD needs your help improving the softwareworld, please donate: http:/...
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
...th => / ^[-^!$#%&''*+\/=?`{|}~.\w]+ @[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])* (\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*)+$/x, :message => "must be a valid email address", :on => :create def before_create self.hashed_password = User.hash_password(self.password) end def after_create @password = nil end def self.hash_password(password) Digest::SHA1.hexdigest(password) end def self.login(username, password, account_id) hashed_password = hash_password(password || "") find_by_username_and_hashed_password_and_ac...
2005 Dec 17
1
lost in an ActiveRecord::StatementInvalid
...this: require ''digest/sha1'' class User < ActiveRecord::Base attr_accessor :password attr_accessible :name, :password validates_uniqueness_of :name validates_presence_of :name, :password def before_create self.hashed_password = User.hash_password(self.password) end def after_create @password = nil end private def self.hash_password(password) Digest::SHA1.hexdigest(password) end end Any hints? -- fxn PS: The full stack trace is here: http://rafb.net/paste/results/ dFbMa...
2005 Jul 13
0
Testing failing
...hash_pass ), @profile_ron.hashed_password end The problem is that @profile_ron.hashed_password never changes. I''ve put a bunch of logging and debugging code in and the problem actually seems to be in the before_create method. After the assign, self.hashed_password is nil. The hash_password method calculates the hash, but we get nil back. Any ideas what I''m doing wrong? I haven''t tried the log in method yet, I wanted the hash test to work first. require "digest/sha1" class Profile < ActiveRecord::Base validates_presence_of :name, :ema...
2006 Apr 28
7
a simple problem but difficult
how can i access to a collection that was created in the same control and the data that a want to access isn?t the id the collection has : id, usuario, comandancia comandancia is the data to access the question is how to access comandancia in @acceso this code is wrong : def new @catelemento = Catelemento.new @acceso= Catacceso.find(:all, :conditions
2006 Aug 07
2
NoMethod Error: Modifying Location of support modules
I''m trying to follow along with the Agile Development with Ruby on Rails book and have encountered a problem with code having the following syntax (partial class provided): require "digest/sha1" class User < ActiveRecord::Base private def self.hash_password(password) Digest:SHA1.hexdigest(password) end end I''m getting an error as: undefined method `hexdigest'' for :SHA1:Symbol I have installed Ruby 1.8.4. How can I correct this error? I''m running on Mac OS X and have followed the build instructions for Macs to in...
2008 Jan 17
6
how to control self.method access
i think self.method just like class method,so if i want to define it as a private method,i should use private_class_method :my_method but i found follow code in < <Agile Web Development with Rails>> private def self.hash_password(password) Digest::SHA1.hexdigest(password) end just a mistake or there have some thing which i cannot get? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group,...
2006 Jul 24
6
error_messages_for not working
...lass="loginbg"> <%= form_tag(:controller => "login", :action => "register_user") %> <%= error_messages_for(:user) %> ... Controller: community_controller.rb def register_user # begin @user = User.new(params["user"]) @user.passwd = User.hash_password(params["user"]["passwd"]) if @user.save! redirect_to(:controller => "profile", :action => "createprofile") else render(:template => "login/index") end # rescue Exception => exc # flash[:notice] = "General error in registration =...
2007 Dec 07
1
CentOP 5.1 Problem with smbldap-passwd
...my $shadowLastChange=int(time()/86400); my $modify; if ($< != 0) { $modify = $ldap_master->modify ( "$dn", changes => [ replace => [userPassword => "$hash_password"], replace => [shadowLastChange => "$shadowLastChange"] ] ); } else { $modify = $ldap_master->modify ( &quo...
2007 Dec 31
1
Agile Web Dev w/Rails - Password Change
Happy New Year everyone. Just wondering if anyone has coded the ability to allow a user to change their password following the way the book (second edition) implements administration. Seems like I should be able to cut out the password/password_confirmation portion of ''add_user'' form to create a ''change_pass'' form. The problem is I''m not sure how to
2006 Mar 13
7
Problem with params
I''ve got a User model, which holds the following (excerpt): def try_to_authenticate User.authenticate(self.username, self.password) end .. private def self.hash_password(password) Digest::SHA1.hexdigest(password) end def self.authenticate(username, password) @user = User.find(:all, :conditions => ["username = ? AND password = ?", params[:username], self.hash_password(params[:password])) if @user.blan...
2006 Jun 16
2
Problem with User Login from Agile Web Development
...d of the name that was passed to the self.login method. I checked the code multiple times and even downloaded the files as the book had an error in another part of the model but can''t find the problem. The code in the model is: def self.login(user_name, password) hashed_password = hash_password(password || "") find(:first, :conditions => ["user_name = ? and hashed_password = ?", user_name, hashed_password]) end # Log in if the name and password (after hashing) match the database, # or if the name matches an entry in the database with no password...
2006 Aug 14
2
Change password
Is there an addition to the Rails Recipe or the method in AWDWR to allow a user to change his/ her password? I have put something together that does all the work again - mostly because I''m not sure how to leverage on methods like ''password='' that are defined in the model. Has anyone got a ready sample that I could learn from? Right now, I''m basically
2006 Mar 29
5
How to skip password validation when updating other fields?
Besides the hashed password, which is saved to db, I have two password-attributes in my User model: attr_accessor :password, :password_confirmation I have validations on these attributes, and I need them to work both on create and update, since I have pages for changing and resetting the password. Now when I want to update just the user''s login name, I guess I have the next
2006 Jan 25
12
DRY in Models
I am building an app right now that needs to grant access to three levels of members right now - each will have their own table in the DB. When creating the add_user action I am converting the password into a hashed password through the model. The way I am doing this right now, I will inevitably end up with repeated code in three different models. Is there a way I can define this code in
2006 Jul 16
0
Problems with validates_lenght_of
...orter", :too_short => "must be longer", :on => :update, :allow_nil => true before_update :before_create after_update :after_create def before_create if @password self.hashed_password = User.hash_password(@password) end end def after_create @password = nil end ... end The idea is, that if the password supplied by the form is nil, the model won''t change hashed_password. However, the view gives me an error message about password being too short, when I leave the passwo...
2006 Jan 10
0
problem with cookies in tests (TDD)
...browser, but I can''t seem to make the test pass. account_signup_test.rb def test_should_pass_if_logout_destroys_cookie_data post :login, { :user => { :login => ''ben'', :password => ''password'' }, :remember => 1 } assert_equal(User.hash_password(''password''), cookies["password"][0]) assert_equal(''ben'', cookies["login"][0]) get :logout assert_nil cookies["password"][0] assert_nil cookies["login"][0] end account_controller.rb def logout sessi...
2006 Feb 27
4
update_attribute with Validation?
Does anyone know of a way to update individual attributes with validation? update_attribute disables the validation checks in the record model, so I''m wondering if there''s a workaround for this. In my application, I want to allow the user to update some or all the attributes without having to enter :password and :password_confirmation, both of which are subject to
2006 Jan 16
4
Question about self and private
Hi! There''s something I don''t understand yet about static/private methods. I hope someone can explain... E.g.: class SayHello def hello(who) puts "Hello, " + who + "!" end def self.say(words) puts words end end hello = SayHello.new hello.hello "World" : Hello World! hello.say "hi" : Error SayHello.say