search for: encrypt_password

Displaying 11 results from an estimated 11 matches for "encrypt_password".

Did you mean: crypt_password
2011 Oct 14
2
before_save :encrypt_password
I am having a problem finding the best way to make a "before_save :encrypt_password" conditional. I have to at times update user model attributes but each time I do this the password is reencrypted because of the above. I need to differentiate between when the user is first logging in and the password does need to be encrypted, and when they are already logged in and the &q...
2006 Mar 04
4
Two quick newbie questions
...arams[:user]) @user = User.new(params[:user => ''username'', :user => ''password'']) ... given this model: class User < ActiveRecord::Base attr_accessor :password attr_accessible :username, :password def before_create self.hashed_password = User.encrypt_password(self.password) end def after_create @password = nil end def self.login(username, password) hashed_password = encrypt_password(password || '''') find(:first, :conditions => [''username = ? and hashed_password =?'', username,...
2006 Jul 02
2
NoMethodError in Unit Test - Rails Newcomer
...ost of my apps problems till now. I keep getting the NoMethodError, and can''t understand why. Model: customer.rb class Customer < ActiveRecord::Base ... def self.password=(pass) @password=pass salt = Customer.random_string(10) if !salt? self.hashed_password = Customer.encrypt_password(@password, salt) end end Test: customer_test.rb require File.dirname(__FILE__) + ''/../test_helper'' class CustomerTest < Test::Unit::TestCase self.use_instantiated_fixtures = true fixtures :customers ... # change password @longbob.password = @longbob.password_confirma...
2008 Jun 20
15
before_save model callback rspec testing
hi all, i''m learning rspec and i can''t figure out how to test if a callback is executed in a model. my model code is: class User < ActiveRecord::Base before_save :encrypt_password ... def encrypt(password) self.class.encrypt(password, salt) end thanks a lot, cs. -- Posted via http://www.ruby-forum.com/.
2008 Jun 29
3
Working around/with Restful Authentication
I''m using Restful Authentication, and the code to create a user is pretty straight forward - there is a before_save action and a before_create action: before_save :encrypt_password before_create :make_activation_code But for some reason when I try to create a user programmatically in the controller like this: User.new(:email => ''user-n8tE+Mx9DRM@public.gmane.org'', :password => ''123456'', :password_confirmation => ''12345...
2006 Aug 09
1
question about enforcing constraints in the model
I have a user model and a status model. Each user has a specific status (accepted, rejected, declined, etc). I have a form that allows the adminstrator to change certain options for a user, including their status. I''m using a drop down menu populated with the different status values, and a default option that says "Choose a new status" with a value of "". I want to
2011 Jul 19
0
Ruby on Rails Tutorial Chapter 8 Signup Success
...:format => {:with => email_regex}, :uniqueness => {:case_sensitive => false} validates :password, :presence => true, :confirmation => true, :length => {:within => 6..40} before_save :encrypt_password def has_password?(submitted_password) encrypted_password == encrypt(submitted_password) end class << self def authenticate(email, submitted_password) user = User.find_by_email(email) return nil if user.nil? return user if user....
2007 Mar 26
2
Strange Record not saved errors
I have a site with an acts_as_authenticated based login which has started throwing up some strange errors. Until a few days ago everything worked fine but all of a sudden ''RecordNotSaved'' errors are popping up in my logs. When I check the database, it looks like the record _is_ saved but I think users get an error so I''m starting to see a lot of double/triple entries
2009 Nov 09
4
Decrypt a admin password (with salt)
...lf.encrypt(password, salt) Digest::SHA1.hexdigest("--#{salt}--#{password}--") end # Encrypts the password with the user salt def encrypt(password) self.class.encrypt(password, salt) end def authenticated?(password) crypted_password = encrypt(password) end def encrypt_password self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--# {login}--") if new_record? self.crypted_password = encrypt(password) end please do tell me...
2006 Jul 17
19
updating model
hello, i am writing a simple user login system. when registering a user account, i have two field: password password_confirmation which are validated using validates_presence_of validates_confirmation_of and these are then used to generate a password hash which is stored in my database when i want to update the record (without changing the password and entering new values for password and
2007 Nov 17
18
Syntax Problem
I admit I am stuck. I am converting a legacy php site to ROR. The old site uses MD5, a security flaw waiting to happen. I upgraded to AAA and am adding code in the session_controller.rb file to see if crypted_password is blank. If it is, crypt and check the password against the old md5 version and write it in the new crypted_password field. Here is my code add on before the logged_in?: def