sorcery 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sorcery might be problematic. Click here for more details.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/sorcery/model.rb +2 -2
- data/lib/sorcery/model/adapters/mongoid.rb +10 -5
- data/lib/sorcery/model/submodules/reset_password.rb +5 -3
- data/sorcery.gemspec +2 -2
- data/spec/Gemfile.lock +0 -3
- data/spec/rails3/Gemfile.lock +0 -3
- data/spec/rails3/spec/user_reset_password_spec.rb +1 -1
- data/spec/rails3_mongoid/Gemfile.lock +0 -3
- data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +12 -4
- data/spec/sinatra/Gemfile +3 -0
- data/spec/sinatra/Gemfile.lock +16 -33
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -29,7 +29,7 @@ Example Rails 3 app using sorcery: https://github.com/NoamB/sorcery-example-app
|
|
29
29
|
|
30
30
|
Example Sinatra app using sorcery: https://github.com/NoamB/sorcery-example-app-sinatra
|
31
31
|
|
32
|
-
Documentation: http://rubydoc.info/gems/sorcery/0.5.
|
32
|
+
Documentation: http://rubydoc.info/gems/sorcery/0.5.1/frames
|
33
33
|
|
34
34
|
Check out the tutorials in the github wiki!
|
35
35
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/lib/sorcery/model.rb
CHANGED
@@ -32,7 +32,7 @@ module Sorcery
|
|
32
32
|
|
33
33
|
self.class_eval do
|
34
34
|
field sorcery_config.username_attribute_name, type: String
|
35
|
-
field sorcery_config.password_attribute_name, type: String
|
35
|
+
#field sorcery_config.password_attribute_name, type: String
|
36
36
|
field sorcery_config.email_attribute_name, type: String unless sorcery_config.username_attribute_name == sorcery_config.email_attribute_name
|
37
37
|
field sorcery_config.crypted_password_attribute_name, type: String
|
38
38
|
field sorcery_config.salt_attribute_name, type: String
|
@@ -122,7 +122,7 @@ module Sorcery
|
|
122
122
|
# encrypts password with salt and saves it.
|
123
123
|
def encrypt_password
|
124
124
|
config = sorcery_config
|
125
|
-
|
125
|
+
self.send(:"#{config.salt_attribute_name}=", new_salt = generate_random_token) if !config.salt_attribute_name.nil?
|
126
126
|
self.send(:"#{config.crypted_password_attribute_name}=", self.class.encrypt(self.send(config.password_attribute_name),new_salt))
|
127
127
|
end
|
128
128
|
|
@@ -15,11 +15,12 @@ module Sorcery
|
|
15
15
|
|
16
16
|
module ClassMethods
|
17
17
|
def find_by_credentials(credentials)
|
18
|
-
where(
|
18
|
+
where(sorcery_config.username_attribute_name => credentials[0]).first
|
19
19
|
end
|
20
20
|
|
21
21
|
def find_by_provider_and_uid(provider, uid)
|
22
|
-
|
22
|
+
user_klass = ::Sorcery::Controller::Config.user_class
|
23
|
+
where(user_klass.sorcery_config.provider_attribute_name => provider, user_klass.sorcery_config.provider_uid_attribute_name => uid).first
|
23
24
|
end
|
24
25
|
|
25
26
|
def find_by_id(id)
|
@@ -27,15 +28,15 @@ module Sorcery
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def find_by_activation_token(token)
|
30
|
-
where(
|
31
|
+
where(sorcery_config.activation_token_attribute_name => token).first
|
31
32
|
end
|
32
33
|
|
33
34
|
def find_by_remember_me_token(token)
|
34
|
-
where(
|
35
|
+
where(sorcery_config.remember_me_token_attribute_name => token).first
|
35
36
|
end
|
36
37
|
|
37
38
|
def find_by_username(username)
|
38
|
-
where(
|
39
|
+
where(sorcery_config.username_attribute_name => username).first
|
39
40
|
end
|
40
41
|
|
41
42
|
def transaction(&blk)
|
@@ -46,6 +47,10 @@ module Sorcery
|
|
46
47
|
where(token_attr_name => token).first
|
47
48
|
end
|
48
49
|
|
50
|
+
def find_by_email(email)
|
51
|
+
where(sorcery_config.email_attribute_name => email).first
|
52
|
+
end
|
53
|
+
|
49
54
|
def get_current_users
|
50
55
|
config = sorcery_config
|
51
56
|
where(config.last_activity_at_attribute_name.ne => nil) \
|
@@ -32,11 +32,12 @@ module Sorcery
|
|
32
32
|
|
33
33
|
reset!
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
|
+
base.extend(ClassMethods)
|
37
|
+
|
36
38
|
base.sorcery_config.after_config << :validate_mailer_defined
|
37
39
|
base.sorcery_config.after_config << :define_reset_password_mongoid_fields if defined?(Mongoid) and base.ancestors.include?(Mongoid::Document)
|
38
40
|
|
39
|
-
base.extend(ClassMethods)
|
40
41
|
base.send(:include, TemporaryToken)
|
41
42
|
base.send(:include, InstanceMethods)
|
42
43
|
|
@@ -84,7 +85,8 @@ module Sorcery
|
|
84
85
|
# Clears token and tries to update the new password for the user.
|
85
86
|
def change_password!(new_password)
|
86
87
|
clear_reset_password_token
|
87
|
-
|
88
|
+
self.send(:"#{sorcery_config.password_attribute_name}=", new_password)
|
89
|
+
save
|
88
90
|
end
|
89
91
|
|
90
92
|
protected
|
data/sorcery.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sorcery}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Noam Ben Ari"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-11}
|
13
13
|
s.description = %q{Provides common authentication needs such as signing in/out, activating by email and resetting password.}
|
14
14
|
s.email = %q{nbenari@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/Gemfile.lock
CHANGED
@@ -3,12 +3,10 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
sorcery (0.5.0)
|
5
5
|
bcrypt-ruby (~> 2.1.4)
|
6
|
-
json (>= 1.5.1)
|
7
6
|
oauth (>= 0.4.4)
|
8
7
|
oauth (>= 0.4.4)
|
9
8
|
oauth2 (>= 0.1.1)
|
10
9
|
oauth2 (>= 0.1.1)
|
11
|
-
rails (>= 3.0.0)
|
12
10
|
|
13
11
|
GEM
|
14
12
|
remote: http://rubygems.org/
|
@@ -54,7 +52,6 @@ GEM
|
|
54
52
|
multipart-post (~> 1.1.0)
|
55
53
|
rack (< 2, >= 1.1.0)
|
56
54
|
i18n (0.5.0)
|
57
|
-
json (1.5.1)
|
58
55
|
linecache19 (0.5.11)
|
59
56
|
ruby_core_source (>= 0.1.4)
|
60
57
|
mail (2.2.13)
|
data/spec/rails3/Gemfile.lock
CHANGED
@@ -4,12 +4,10 @@ PATH
|
|
4
4
|
oauth (0.4.4)
|
5
5
|
sorcery (0.5.0)
|
6
6
|
bcrypt-ruby (~> 2.1.4)
|
7
|
-
json (>= 1.5.1)
|
8
7
|
oauth (>= 0.4.4)
|
9
8
|
oauth (>= 0.4.4)
|
10
9
|
oauth2 (>= 0.1.1)
|
11
10
|
oauth2 (>= 0.1.1)
|
12
|
-
rails (>= 3.0.0)
|
13
11
|
|
14
12
|
GEM
|
15
13
|
remote: http://rubygems.org/
|
@@ -55,7 +53,6 @@ GEM
|
|
55
53
|
multipart-post (~> 1.1.0)
|
56
54
|
rack (< 2, >= 1.1.0)
|
57
55
|
i18n (0.5.0)
|
58
|
-
json (1.5.1)
|
59
56
|
linecache19 (0.5.11)
|
60
57
|
ruby_core_source (>= 0.1.4)
|
61
58
|
mail (2.2.13)
|
@@ -142,7 +142,7 @@ describe "User with reset_password submodule" do
|
|
142
142
|
ActionMailer::Base.deliveries.size.should == old_size + 1
|
143
143
|
end
|
144
144
|
|
145
|
-
it "when
|
145
|
+
it "when change_password! is called, should delete reset_password_token" do
|
146
146
|
create_new_user
|
147
147
|
@user.deliver_reset_password_instructions!
|
148
148
|
@user.reset_password_token.should_not be_nil
|
@@ -4,12 +4,10 @@ PATH
|
|
4
4
|
oauth (0.4.4)
|
5
5
|
sorcery (0.5.0)
|
6
6
|
bcrypt-ruby (~> 2.1.4)
|
7
|
-
json (>= 1.5.1)
|
8
7
|
oauth (>= 0.4.4)
|
9
8
|
oauth (>= 0.4.4)
|
10
9
|
oauth2 (>= 0.1.1)
|
11
10
|
oauth2 (>= 0.1.1)
|
12
|
-
rails (>= 3.0.0)
|
13
11
|
|
14
12
|
GEM
|
15
13
|
remote: http://rubygems.org/
|
@@ -57,7 +55,6 @@ GEM
|
|
57
55
|
multipart-post (~> 1.1.0)
|
58
56
|
rack (< 2, >= 1.1.0)
|
59
57
|
i18n (0.5.0)
|
60
|
-
json (1.5.1)
|
61
58
|
linecache19 (0.5.11)
|
62
59
|
ruby_core_source (>= 0.1.4)
|
63
60
|
mail (2.2.13)
|
@@ -20,7 +20,7 @@ describe "User with reset_password submodule" do
|
|
20
20
|
|
21
21
|
specify { @user.should respond_to(:deliver_reset_password_instructions!) }
|
22
22
|
|
23
|
-
specify { @user.should respond_to(:
|
23
|
+
specify { @user.should respond_to(:change_password!) }
|
24
24
|
|
25
25
|
it "should respond to .load_from_reset_password_token" do
|
26
26
|
User.should respond_to(:load_from_reset_password_token)
|
@@ -135,7 +135,7 @@ describe "User with reset_password submodule" do
|
|
135
135
|
ActionMailer::Base.deliveries.size.should == old_size + 1
|
136
136
|
end
|
137
137
|
|
138
|
-
it "when
|
138
|
+
it "when change_password! is called, should delete reset_password_token" do
|
139
139
|
create_new_user
|
140
140
|
@user.deliver_reset_password_instructions!
|
141
141
|
@user.reset_password_token.should_not be_nil
|
@@ -164,11 +164,19 @@ describe "User with reset_password submodule" do
|
|
164
164
|
@user.deliver_reset_password_instructions!
|
165
165
|
ActionMailer::Base.deliveries.size.should == old_size + 2
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
|
+
it "should encrypt properly on reset" do
|
169
|
+
create_new_user
|
170
|
+
@user.deliver_reset_password_instructions!
|
171
|
+
@user.change_password!("blagu")
|
172
|
+
Sorcery::CryptoProviders::BCrypt.matches?(@user.crypted_password,"blagu",@user.salt).should be_true
|
173
|
+
end
|
174
|
+
|
168
175
|
it "if mailer is nil on activation, throw exception!" do
|
169
176
|
expect{sorcery_reload!([:reset_password])}.to raise_error(ArgumentError)
|
170
177
|
end
|
171
|
-
|
178
|
+
|
179
|
+
|
172
180
|
end
|
173
181
|
|
174
182
|
end
|
data/spec/sinatra/Gemfile
CHANGED
@@ -2,9 +2,12 @@ source 'http://rubygems.org'
|
|
2
2
|
|
3
3
|
gem 'sinatra', '>= 1.2.0'
|
4
4
|
gem 'sqlite3-ruby', :require => 'sqlite3'
|
5
|
+
gem 'activerecord', '>= 3.0.3'
|
6
|
+
gem 'actionmailer', '>= 3.0.3'
|
5
7
|
gem "sorcery", '>= 0.1.0', :path => '../../'
|
6
8
|
|
7
9
|
group :development, :test do
|
10
|
+
gem "rake"
|
8
11
|
gem "rspec", "~> 2.5.0"
|
9
12
|
gem 'ruby-debug19'
|
10
13
|
gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
|
data/spec/sinatra/Gemfile.lock
CHANGED
@@ -3,43 +3,38 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
sorcery (0.5.0)
|
5
5
|
bcrypt-ruby (~> 2.1.4)
|
6
|
-
json (>= 1.5.1)
|
7
6
|
oauth (>= 0.4.4)
|
8
7
|
oauth (>= 0.4.4)
|
9
8
|
oauth2 (>= 0.1.1)
|
10
9
|
oauth2 (>= 0.1.1)
|
11
|
-
rails (>= 3.0.0)
|
12
10
|
|
13
11
|
GEM
|
14
12
|
remote: http://rubygems.org/
|
15
13
|
specs:
|
16
14
|
abstract (1.0.0)
|
17
|
-
actionmailer (3.0.
|
18
|
-
actionpack (= 3.0.
|
19
|
-
mail (~> 2.2.
|
20
|
-
actionpack (3.0.
|
21
|
-
activemodel (= 3.0.
|
22
|
-
activesupport (= 3.0.
|
15
|
+
actionmailer (3.0.5)
|
16
|
+
actionpack (= 3.0.5)
|
17
|
+
mail (~> 2.2.15)
|
18
|
+
actionpack (3.0.5)
|
19
|
+
activemodel (= 3.0.5)
|
20
|
+
activesupport (= 3.0.5)
|
23
21
|
builder (~> 2.1.2)
|
24
22
|
erubis (~> 2.6.6)
|
25
23
|
i18n (~> 0.4)
|
26
24
|
rack (~> 1.2.1)
|
27
25
|
rack-mount (~> 0.6.13)
|
28
|
-
rack-test (~> 0.5.
|
26
|
+
rack-test (~> 0.5.7)
|
29
27
|
tzinfo (~> 0.3.23)
|
30
|
-
activemodel (3.0.
|
31
|
-
activesupport (= 3.0.
|
28
|
+
activemodel (3.0.5)
|
29
|
+
activesupport (= 3.0.5)
|
32
30
|
builder (~> 2.1.2)
|
33
31
|
i18n (~> 0.4)
|
34
|
-
activerecord (3.0.
|
35
|
-
activemodel (= 3.0.
|
36
|
-
activesupport (= 3.0.
|
32
|
+
activerecord (3.0.5)
|
33
|
+
activemodel (= 3.0.5)
|
34
|
+
activesupport (= 3.0.5)
|
37
35
|
arel (~> 2.0.2)
|
38
36
|
tzinfo (~> 0.3.23)
|
39
|
-
|
40
|
-
activemodel (= 3.0.3)
|
41
|
-
activesupport (= 3.0.3)
|
42
|
-
activesupport (3.0.3)
|
37
|
+
activesupport (3.0.5)
|
43
38
|
addressable (2.2.5)
|
44
39
|
archive-tar-minitar (0.5.2)
|
45
40
|
arel (2.0.7)
|
@@ -54,7 +49,6 @@ GEM
|
|
54
49
|
multipart-post (~> 1.1.0)
|
55
50
|
rack (< 2, >= 1.1.0)
|
56
51
|
i18n (0.5.0)
|
57
|
-
json (1.5.1)
|
58
52
|
linecache19 (0.5.11)
|
59
53
|
ruby_core_source (>= 0.1.4)
|
60
54
|
mail (2.2.15)
|
@@ -75,19 +69,6 @@ GEM
|
|
75
69
|
rack (>= 1.0.0)
|
76
70
|
rack-test (0.5.7)
|
77
71
|
rack (>= 1.0)
|
78
|
-
rails (3.0.3)
|
79
|
-
actionmailer (= 3.0.3)
|
80
|
-
actionpack (= 3.0.3)
|
81
|
-
activerecord (= 3.0.3)
|
82
|
-
activeresource (= 3.0.3)
|
83
|
-
activesupport (= 3.0.3)
|
84
|
-
bundler (~> 1.0)
|
85
|
-
railties (= 3.0.3)
|
86
|
-
railties (3.0.3)
|
87
|
-
actionpack (= 3.0.3)
|
88
|
-
activesupport (= 3.0.3)
|
89
|
-
rake (>= 0.8.7)
|
90
|
-
thor (~> 0.14.4)
|
91
72
|
rake (0.8.7)
|
92
73
|
rspec (2.5.0)
|
93
74
|
rspec-core (~> 2.5.0)
|
@@ -114,7 +95,6 @@ GEM
|
|
114
95
|
rack (~> 1.1)
|
115
96
|
tilt (< 2.0, >= 1.2.2)
|
116
97
|
sqlite3-ruby (1.3.2)
|
117
|
-
thor (0.14.6)
|
118
98
|
tilt (1.2.2)
|
119
99
|
timecop (0.3.5)
|
120
100
|
treetop (1.4.9)
|
@@ -125,6 +105,9 @@ PLATFORMS
|
|
125
105
|
ruby
|
126
106
|
|
127
107
|
DEPENDENCIES
|
108
|
+
actionmailer (>= 3.0.3)
|
109
|
+
activerecord (>= 3.0.3)
|
110
|
+
rake
|
128
111
|
rspec (~> 2.5.0)
|
129
112
|
ruby-debug19
|
130
113
|
simplecov (>= 0.3.8)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sorcery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Noam Ben Ari
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-11 00:00:00 +03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|