userify 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/userify/user.rb +11 -13
- metadata +2 -2
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.4"
|
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
@@ -13,19 +13,17 @@ module Userify
|
|
13
13
|
attr_accessible :username, :email, :password, :fullname
|
14
14
|
attr_accessor :password
|
15
15
|
|
16
|
-
validates_presence_of :username
|
17
16
|
validates_length_of :username, :maximum => columns_hash['username'].limit
|
18
|
-
validates_uniqueness_of :username
|
19
|
-
validates_presence_of :email
|
17
|
+
validates_uniqueness_of :username, :case_sensitive => false
|
20
18
|
validates_length_of :email, :maximum => columns_hash['email'].limit
|
19
|
+
validates_format_of :email, :with => /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/
|
21
20
|
validates_uniqueness_of :email, :case_sensitive => false
|
22
|
-
validates_format_of :email, :with => /.+@.+\..+/
|
23
21
|
validates_presence_of :password, :if => :password_required?
|
24
22
|
validates_length_of :fullname, :maximum => columns_hash['fullname'].limit, :allow_nil => true
|
25
23
|
|
26
|
-
before_validation
|
27
|
-
|
28
|
-
|
24
|
+
before_validation :userify_before_validation
|
25
|
+
before_validation_on_create :userify_before_validation_on_create
|
26
|
+
before_save :userify_before_save
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
@@ -86,21 +84,21 @@ module Userify
|
|
86
84
|
end
|
87
85
|
|
88
86
|
def password_required?
|
89
|
-
encrypted_password.blank?
|
87
|
+
encrypted_password.blank?
|
90
88
|
end
|
91
89
|
|
92
90
|
def userify_before_validation
|
93
91
|
self.email.downcase! unless self.email.nil?
|
94
92
|
end
|
95
93
|
|
96
|
-
def
|
97
|
-
self.encrypted_password = encrypt(password) unless self.password.blank?
|
98
|
-
end
|
99
|
-
|
100
|
-
def userify_before_create
|
94
|
+
def userify_before_validation_on_create
|
101
95
|
self.salt = UID.new(27).to_s
|
102
96
|
set_token 24.hours.from_now
|
103
97
|
end
|
98
|
+
|
99
|
+
def userify_before_save
|
100
|
+
self.encrypted_password = encrypt(password) unless self.password.blank?
|
101
|
+
end
|
104
102
|
end
|
105
103
|
|
106
104
|
module ClassMethods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: userify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenn Ejima
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-05 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|