lib/devise/models/lockable.rb in devise-3.2.3 vs lib/devise/models/lockable.rb in devise-3.2.4

- old
+ new

@@ -20,11 +20,11 @@ # * +unlock_keys+: the keys you want to use when locking and unlocking an account # module Lockable extend ActiveSupport::Concern - delegate :lock_strategy_enabled?, :unlock_strategy_enabled?, :to => "self.class" + delegate :lock_strategy_enabled?, :unlock_strategy_enabled?, to: "self.class" def self.required_fields(klass) attributes = [] attributes << :failed_attempts if klass.lock_strategy_enabled?(:failed_attempts) attributes << :locked_at if klass.unlock_strategy_enabled?(:time) @@ -34,27 +34,27 @@ end # Lock a user setting its locked_at to actual time. # * +opts+: Hash options if you don't want to send email # when you lock access, you could pass the next hash - # `{ :send_instructions => false } as option`. + # `{ send_instructions: false } as option`. def lock_access!(opts = { }) self.locked_at = Time.now.utc if unlock_strategy_enabled?(:email) && opts.fetch(:send_instructions, true) send_unlock_instructions else - save(:validate => false) + save(validate: false) end end # Unlock a user by cleaning locked_at and failed_attempts. def unlock_access! self.locked_at = nil self.failed_attempts = 0 if respond_to?(:failed_attempts=) self.unlock_token = nil if respond_to?(:unlock_token=) - save(:validate => false) + save(validate: false) end # Verifies whether a user is locked or not. def access_locked? !!locked_at && !lock_expired? @@ -62,11 +62,11 @@ # Send unlock instructions by email def send_unlock_instructions raw, enc = Devise.token_generator.generate(self.class, :unlock_token) self.unlock_token = enc - self.save(:validate => false) + self.save(validate: false) send_devise_notification(:unlock_instructions, raw, {}) raw end # Resend the unlock instructions if the user is locked. @@ -102,10 +102,10 @@ self.failed_attempts ||= 0 self.failed_attempts += 1 if attempts_exceeded? lock_access! unless access_locked? else - save(:validate => false) + save(validate: false) end false end end