Skip to content
Browse files

added bcrypt as a dependency and small tweaks.

  • Loading branch information...
1 parent 9698d2e commit 6508aa8710d33cf5aefe5010578f8692fb6d9334 @NoamB committed Feb 16, 2011
Showing with 4 additions and 5 deletions.
  1. +1 −1 Rakefile
  2. +3 −4 lib/sorcery/model/submodules/reset_password.rb
View
2 Rakefile
@@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
# gem.add_development_dependency 'rspec', '> 1.2.3'
- # gem.add_runtime_dependency 'bcrypt-ruby', '~> 2.1.4'
+ gem.add_runtime_dependency 'bcrypt-ruby', '~> 2.1.4'
end
Jeweler::RubygemsDotOrgTasks.new
View
7 lib/sorcery/model/submodules/reset_password.rb
@@ -39,7 +39,7 @@ def load_from_reset_password_token(token)
return nil if token.blank?
user = where("#{@sorcery_config.reset_password_token_attribute_name} = ?", token).first
if !user.blank? && !@sorcery_config.reset_password_expiration_period.nil?
- return (user.reset_password_token_valid? ? user : nil)
+ return user.reset_password_token_valid? ? user : nil
end
user
end
@@ -58,10 +58,9 @@ module InstanceMethods
def deliver_reset_password_instructions!
config = sorcery_config
# hammering protection
- return if self.send(config.reset_password_email_sent_at_attribute_name) && self.send(config.reset_password_email_sent_at_attribute_name) > config.reset_password_time_between_emails.ago.utc
-
+ return if config.reset_password_time_between_emails && self.send(config.reset_password_email_sent_at_attribute_name) && self.send(config.reset_password_email_sent_at_attribute_name) > config.reset_password_time_between_emails.ago.utc
self.send(:"#{config.reset_password_token_attribute_name}=", generate_random_code)
- self.send(:"#{config.reset_password_token_expires_at_attribute_name}=", Time.now.utc+config.reset_password_expiration_period) if config.reset_password_expiration_period
+ self.send(:"#{config.reset_password_token_expires_at_attribute_name}=", Time.now.utc + config.reset_password_expiration_period) if config.reset_password_expiration_period
self.send(:"#{config.reset_password_email_sent_at_attribute_name}=", Time.now.utc)
self.class.transaction do
self.save!(:validate => false)

0 comments on commit 6508aa8

Please sign in to comment.
Something went wrong with that request. Please try again.