userify 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/userify/user.rb +16 -6
- metadata +1 -1
data/Rakefile
CHANGED
@@ -35,7 +35,7 @@ task :default => ['test:all', 'test:features']
|
|
35
35
|
|
36
36
|
gem_spec = Gem::Specification.new do |gem_spec|
|
37
37
|
gem_spec.name = "userify"
|
38
|
-
gem_spec.version = "0.2.
|
38
|
+
gem_spec.version = "0.2.3"
|
39
39
|
gem_spec.summary = "Super simple authentication system for Rails, using username, email and password."
|
40
40
|
gem_spec.email = "kenn.ejima <at> gmail.com"
|
41
41
|
gem_spec.homepage = "http://github.com/kenn/userify"
|
data/lib/userify/user.rb
CHANGED
@@ -23,12 +23,9 @@ module Userify
|
|
23
23
|
validates_presence_of :password, :if => :password_required?
|
24
24
|
validates_length_of :fullname, :maximum => columns_hash['fullname'].limit, :allow_nil => true
|
25
25
|
|
26
|
-
before_validation
|
27
|
-
before_save
|
28
|
-
before_create
|
29
|
-
record.salt = UID.new(27).to_s
|
30
|
-
record.set_token 24.hours.from_now
|
31
|
-
}
|
26
|
+
before_validation :userify_before_validation
|
27
|
+
before_save :userify_before_save
|
28
|
+
before_create :userify_before_create
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
@@ -91,6 +88,19 @@ module Userify
|
|
91
88
|
def password_required?
|
92
89
|
encrypted_password.blank? or !password.blank?
|
93
90
|
end
|
91
|
+
|
92
|
+
def userify_before_validation
|
93
|
+
self.email.downcase! unless self.email.nil?
|
94
|
+
end
|
95
|
+
|
96
|
+
def userify_before_save
|
97
|
+
self.encrypted_password = encrypt(password) unless self.password.blank?
|
98
|
+
end
|
99
|
+
|
100
|
+
def userify_before_create
|
101
|
+
self.salt = UID.new(27).to_s
|
102
|
+
set_token 24.hours.from_now
|
103
|
+
end
|
94
104
|
end
|
95
105
|
|
96
106
|
module ClassMethods
|