simple_auth 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -3
- data/lib/simple_auth/orm/base.rb +12 -1
- data/lib/simple_auth/version.rb +2 -2
- data/spec/spec_helper.rb +20 -0
- metadata +3 -3
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source "http://gems.simplesideias.com.br"
|
2
2
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_auth (1.
|
4
|
+
simple_auth (1.4.0)
|
5
5
|
rails (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
|
-
remote: http://
|
8
|
+
remote: http://gems.simplesideias.com.br/
|
9
9
|
specs:
|
10
10
|
abstract (1.0.0)
|
11
11
|
actionmailer (3.0.7)
|
@@ -35,7 +35,7 @@ GEM
|
|
35
35
|
activesupport (= 3.0.7)
|
36
36
|
activesupport (3.0.7)
|
37
37
|
archive-tar-minitar (0.5.2)
|
38
|
-
arel (2.0.
|
38
|
+
arel (2.0.10)
|
39
39
|
bson (1.3.0)
|
40
40
|
bson_ext (1.3.0)
|
41
41
|
builder (2.1.2)
|
data/lib/simple_auth/orm/base.rb
CHANGED
@@ -2,6 +2,14 @@ module SimpleAuth
|
|
2
2
|
module Orm
|
3
3
|
module Base
|
4
4
|
module InstanceMethods
|
5
|
+
def require_password!
|
6
|
+
@require_password = true
|
7
|
+
end
|
8
|
+
|
9
|
+
def require_password?
|
10
|
+
@require_password
|
11
|
+
end
|
12
|
+
|
5
13
|
def password=(password)
|
6
14
|
@password_changed = true
|
7
15
|
@password = password
|
@@ -28,10 +36,13 @@ module SimpleAuth
|
|
28
36
|
# Mark password as unchanged after erasing passwords,
|
29
37
|
# or it will be marked as changed anyway
|
30
38
|
@password_changed = false
|
39
|
+
|
40
|
+
# Also erase require password
|
41
|
+
@require_password = false
|
31
42
|
end
|
32
43
|
|
33
44
|
def validate_password?
|
34
|
-
new_record? || password_changed?
|
45
|
+
new_record? || password_changed? || require_password?
|
35
46
|
end
|
36
47
|
end
|
37
48
|
|
data/lib/simple_auth/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -112,6 +112,26 @@ shared_examples_for "orm" do
|
|
112
112
|
subject.should be_valid
|
113
113
|
end
|
114
114
|
|
115
|
+
it "should require password when explicitly said so" do
|
116
|
+
subject.require_password!
|
117
|
+
subject.should_not be_valid
|
118
|
+
subject.errors[:password].should_not be_empty
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should require password" do
|
122
|
+
subject.require_password?.should be_false
|
123
|
+
subject.require_password!
|
124
|
+
subject.require_password?.should be_true
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should not require password after saving" do
|
128
|
+
subject.require_password!
|
129
|
+
subject.password = "newpass"
|
130
|
+
subject.password_confirmation = "newpass"
|
131
|
+
subject.save.should be_true
|
132
|
+
subject.require_password?.should be_false
|
133
|
+
end
|
134
|
+
|
115
135
|
it "should require password confirmation when it has changed" do
|
116
136
|
subject.password = "newpass"
|
117
137
|
subject.should_not be_valid
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: simple_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.4.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nando Vieira
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-20 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
requirements: []
|
151
151
|
|
152
152
|
rubyforge_project:
|
153
|
-
rubygems_version: 1.
|
153
|
+
rubygems_version: 1.8.1
|
154
154
|
signing_key:
|
155
155
|
specification_version: 3
|
156
156
|
summary: A simple authentication system for Rails apps
|