simple_user_auth 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_user_auth/version.rb +1 -1
- data/lib/simple_user_auth.rb +3 -8
- metadata +1 -1
data/lib/simple_user_auth.rb
CHANGED
@@ -45,12 +45,7 @@ module SimpleUserAuth
|
|
45
45
|
module ClassInstanceMethods
|
46
46
|
|
47
47
|
def change_password? #:nodoc:
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
# Set this to true to enable replacing encrypted_password with the password accessor. Also enables validations for passwords.
|
52
|
-
def change_password=(bool)
|
53
|
-
@change_password = bool
|
48
|
+
!password.blank?
|
54
49
|
end
|
55
50
|
|
56
51
|
# Checks to see if a user has a particular password
|
@@ -61,7 +56,7 @@ module SimpleUserAuth
|
|
61
56
|
private
|
62
57
|
|
63
58
|
def change_password_validator
|
64
|
-
if change_password?
|
59
|
+
if change_password? && !new_record?
|
65
60
|
errors.add(:old_password, "doesn't match.") unless has_password?(current_password)
|
66
61
|
end
|
67
62
|
end
|
@@ -100,7 +95,7 @@ module SimpleUserAuth
|
|
100
95
|
end
|
101
96
|
|
102
97
|
module ClassMethods
|
103
|
-
# The user model you'll be using.
|
98
|
+
# The user model you'll be using.
|
104
99
|
# e.g. can_sign_in :user
|
105
100
|
def can_sign_in(model)
|
106
101
|
klass = Kernel.const_get(model.to_s.camelize)
|