lib/simple_auth/orm/base.rb in simple_auth-1.3.3 vs lib/simple_auth/orm/base.rb in simple_auth-1.4.0
- old
+ new
@@ -1,9 +1,17 @@
module SimpleAuth
module Orm
module Base
module InstanceMethods
+ def require_password!
+ @require_password = true
+ end
+
+ def require_password?
+ @require_password
+ end
+
def password=(password)
@password_changed = true
@password = password
end
@@ -26,13 +34,16 @@
self.password_confirmation = nil
# Mark password as unchanged after erasing passwords,
# or it will be marked as changed anyway
@password_changed = false
+
+ # Also erase require password
+ @require_password = false
end
def validate_password?
- new_record? || password_changed?
+ new_record? || password_changed? || require_password?
end
end
module ClassMethods
# Find user by its credential.