sorcery 0.7.0 → 0.8.0
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/.travis.yml +3 -0
- data/Gemfile +9 -6
- data/Gemfile.lock +106 -75
- data/README.rdoc +42 -55
- data/Rakefile +32 -7
- data/VERSION +1 -1
- data/lib/generators/sorcery/USAGE +22 -0
- data/lib/generators/sorcery/install_generator.rb +77 -0
- data/lib/generators/sorcery/templates/initializer.rb +417 -0
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +17 -0
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +13 -0
- data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/core.rb +2 -2
- data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/external.rb +1 -1
- data/lib/generators/sorcery/templates/migration/remember_me.rb +15 -0
- data/lib/generators/sorcery/templates/migration/reset_password.rb +17 -0
- data/lib/generators/sorcery/templates/migration/user_activation.rb +17 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +8 -11
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +2 -3
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +25 -10
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +20 -5
- data/lib/sorcery/controller/submodules/external/providers/github.rb +15 -4
- data/lib/sorcery/controller/submodules/external/providers/google.rb +90 -0
- data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +101 -0
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +91 -0
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +3 -2
- data/lib/sorcery/controller/submodules/external/providers/vkontakte.rb +94 -0
- data/lib/sorcery/controller/submodules/external.rb +89 -15
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
- data/lib/sorcery/controller/submodules/remember_me.rb +26 -15
- data/lib/sorcery/controller/submodules/session_timeout.rb +3 -3
- data/lib/sorcery/controller.rb +55 -46
- data/lib/sorcery/crypto_providers/bcrypt.rb +1 -0
- data/lib/sorcery/model/adapters/active_record.rb +21 -1
- data/lib/sorcery/model/adapters/mongo_mapper.rb +56 -0
- data/lib/sorcery/model/adapters/mongoid.rb +23 -4
- data/lib/sorcery/model/submodules/activity_logging.rb +4 -4
- data/lib/sorcery/model/submodules/brute_force_protection.rb +54 -15
- data/lib/sorcery/model/submodules/remember_me.rb +12 -7
- data/lib/sorcery/model/submodules/reset_password.rb +27 -11
- data/lib/sorcery/model/submodules/user_activation.rb +27 -8
- data/lib/sorcery/model/temporary_token.rb +4 -2
- data/lib/sorcery/model.rb +78 -47
- data/lib/sorcery/railties/tasks.rake +2 -0
- data/lib/sorcery.rb +10 -8
- data/sorcery.gemspec +107 -228
- data/spec/Gemfile +1 -1
- data/spec/Gemfile.lock +27 -23
- data/spec/README.md +12 -7
- data/spec/rails3/Gemfile +3 -3
- data/spec/rails3/Gemfile.lock +62 -55
- data/spec/rails3/app/controllers/application_controller.rb +85 -2
- data/spec/rails3/app/mailers/sorcery_mailer.rb +7 -0
- data/spec/rails3/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -0
- data/spec/rails3/config/environments/in_memory.rb +35 -0
- data/spec/rails3/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +2 -0
- data/spec/rails3/spec/controller_activity_logging_spec.rb +16 -6
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +25 -3
- data/spec/rails3/spec/controller_oauth2_spec.rb +260 -20
- data/spec/rails3/spec/controller_oauth_spec.rb +111 -6
- data/spec/rails3/spec/controller_session_timeout_spec.rb +4 -4
- data/spec/rails3/spec/controller_spec.rb +37 -2
- data/spec/rails3/spec/integration_spec.rb +15 -15
- data/spec/rails3/spec/spec_helper.rb +0 -2
- data/spec/rails3_mongo_mapper/.gitignore +4 -0
- data/spec/rails3_mongo_mapper/.rspec +1 -0
- data/spec/{sinatra_modular → rails3_mongo_mapper}/Gemfile +6 -5
- data/spec/rails3_mongo_mapper/Gemfile.lock +156 -0
- data/spec/{sinatra → rails3_mongo_mapper}/Rakefile +3 -3
- data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +122 -0
- data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +2 -0
- data/spec/rails3_mongo_mapper/app/models/authentication.rb +6 -0
- data/spec/rails3_mongo_mapper/app/models/user.rb +5 -0
- data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +14 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +17 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +9 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
- data/spec/rails3_mongo_mapper/config/application.rb +51 -0
- data/spec/rails3_mongo_mapper/config/boot.rb +13 -0
- data/spec/rails3_mongo_mapper/config/environment.rb +5 -0
- data/spec/rails3_mongo_mapper/config/environments/development.rb +30 -0
- data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongo_mapper/config/environments/production.rb +49 -0
- data/spec/rails3_mongo_mapper/config/environments/test.rb +35 -0
- data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +10 -0
- data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +5 -0
- data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +2 -0
- data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +7 -0
- data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +8 -0
- data/spec/rails3_mongo_mapper/config/locales/en.yml +5 -0
- data/spec/rails3_mongo_mapper/config/routes.rb +59 -0
- data/spec/rails3_mongo_mapper/config.ru +4 -0
- data/spec/rails3_mongo_mapper/db/schema.rb +23 -0
- data/spec/rails3_mongo_mapper/db/seeds.rb +7 -0
- data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/public/404.html +26 -0
- data/spec/rails3_mongo_mapper/public/422.html +26 -0
- data/spec/rails3_mongo_mapper/public/500.html +26 -0
- data/spec/rails3_mongo_mapper/public/favicon.ico +0 -0
- data/spec/rails3_mongo_mapper/public/images/rails.png +0 -0
- data/spec/rails3_mongo_mapper/public/javascripts/application.js +2 -0
- data/spec/rails3_mongo_mapper/public/javascripts/controls.js +965 -0
- data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +974 -0
- data/spec/rails3_mongo_mapper/public/javascripts/effects.js +1123 -0
- data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +6001 -0
- data/spec/rails3_mongo_mapper/public/javascripts/rails.js +175 -0
- data/spec/rails3_mongo_mapper/public/robots.txt +5 -0
- data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/script/rails +6 -0
- data/spec/rails3_mongo_mapper/spec/controller_spec.rb +170 -0
- data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +27 -0
- data/spec/rails3_mongo_mapper/spec/spec_helper.rb +55 -0
- data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +9 -0
- data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_spec.rb +37 -0
- data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongoid/Gemfile +2 -1
- data/spec/rails3_mongoid/Gemfile.lock +47 -42
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +19 -0
- data/spec/rails3_mongoid/config/mongoid.yml +1 -1
- data/spec/rails3_mongoid/script/rails +0 -0
- data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +105 -0
- data/spec/rails3_mongoid/spec/controller_spec.rb +52 -1
- data/spec/rails3_mongoid/spec/user_spec.rb +1 -0
- data/spec/shared_examples/controller_oauth2_shared_examples.rb +20 -1
- data/spec/shared_examples/controller_oauth_shared_examples.rb +18 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +72 -42
- data/spec/shared_examples/user_remember_me_shared_examples.rb +1 -1
- data/spec/shared_examples/user_reset_password_shared_examples.rb +81 -28
- data/spec/shared_examples/user_shared_examples.rb +29 -1
- data/spec/sorcery_crypto_providers_spec.rb +14 -1
- metadata +111 -229
- data/lib/generators/sorcery_migration/sorcery_migration_generator.rb +0 -24
- data/lib/generators/sorcery_migration/templates/activity_logging.rb +0 -17
- data/lib/generators/sorcery_migration/templates/brute_force_protection.rb +0 -11
- data/lib/generators/sorcery_migration/templates/remember_me.rb +0 -15
- data/lib/generators/sorcery_migration/templates/reset_password.rb +0 -17
- data/lib/generators/sorcery_migration/templates/user_activation.rb +0 -17
- data/lib/sorcery/controller/adapters/sinatra.rb +0 -115
- data/lib/sorcery/initializers/initializer.rb +0 -199
- data/lib/sorcery/sinatra.rb +0 -4
- data/lib/sorcery/test_helpers/internal/sinatra.rb +0 -74
- data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +0 -74
- data/lib/sorcery/test_helpers/sinatra.rb +0 -88
- data/spec/rails3/Rakefile.unused +0 -7
- data/spec/sinatra/Gemfile +0 -15
- data/spec/sinatra/Gemfile.lock +0 -115
- data/spec/sinatra/authentication.rb +0 -3
- data/spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
- data/spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
- data/spec/sinatra/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
- data/spec/sinatra/filters.rb +0 -27
- data/spec/sinatra/modular.rb +0 -157
- data/spec/sinatra/myapp.rb +0 -133
- data/spec/sinatra/spec/controller_activity_logging_spec.rb +0 -85
- data/spec/sinatra/spec/controller_brute_force_protection_spec.rb +0 -70
- data/spec/sinatra/spec/controller_http_basic_auth_spec.rb +0 -53
- data/spec/sinatra/spec/controller_oauth2_spec.rb +0 -96
- data/spec/sinatra/spec/controller_oauth_spec.rb +0 -100
- data/spec/sinatra/spec/controller_remember_me_spec.rb +0 -64
- data/spec/sinatra/spec/controller_session_timeout_spec.rb +0 -57
- data/spec/sinatra/spec/controller_spec.rb +0 -127
- data/spec/sinatra/spec/spec_helper.rb +0 -45
- data/spec/sinatra/user.rb +0 -6
- data/spec/sinatra/views/test_login.erb +0 -4
- data/spec/sinatra_modular/Gemfile.lock +0 -115
- data/spec/sinatra_modular/Rakefile +0 -11
- data/spec/sinatra_modular/authentication.rb +0 -3
- data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
- data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
- data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
- data/spec/sinatra_modular/filters.rb +0 -27
- data/spec/sinatra_modular/modular.rb +0 -157
- data/spec/sinatra_modular/myapp.rb +0 -133
- data/spec/sinatra_modular/sorcery_mailer.rb +0 -25
- data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +0 -85
- data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +0 -70
- data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +0 -53
- data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +0 -96
- data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +0 -100
- data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +0 -64
- data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +0 -57
- data/spec/sinatra_modular/spec_modular/controller_spec.rb +0 -116
- data/spec/sinatra_modular/spec_modular/spec.opts +0 -2
- data/spec/sinatra_modular/spec_modular/spec_helper.rb +0 -51
- data/spec/sinatra_modular/user.rb +0 -6
- data/spec/sinatra_modular/views/test_login.erb +0 -4
- /data/spec/{sinatra → rails3_mongo_mapper/app/mailers}/sorcery_mailer.rb +0 -0
- /data/spec/{sinatra → rails3_mongo_mapper}/spec/spec.opts +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
|
-
remote:
|
|
2
|
+
remote: ../../
|
|
3
3
|
specs:
|
|
4
|
-
sorcery (0.
|
|
4
|
+
sorcery (0.7.13)
|
|
5
5
|
bcrypt-ruby (~> 3.0.0)
|
|
6
6
|
oauth (~> 0.4.4)
|
|
7
|
-
oauth2 (~> 0.
|
|
7
|
+
oauth2 (~> 0.8.0)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: http://rubygems.org/
|
|
@@ -36,48 +36,51 @@ GEM
|
|
|
36
36
|
activemodel (= 3.0.3)
|
|
37
37
|
activesupport (= 3.0.3)
|
|
38
38
|
activesupport (3.0.3)
|
|
39
|
-
addressable (2.2.6)
|
|
40
39
|
archive-tar-minitar (0.5.2)
|
|
41
|
-
arel (2.0.
|
|
40
|
+
arel (2.0.10)
|
|
42
41
|
bcrypt-ruby (3.0.1)
|
|
43
|
-
bson (1.
|
|
44
|
-
bson_ext (1.
|
|
42
|
+
bson (1.6.0)
|
|
43
|
+
bson_ext (1.6.0)
|
|
44
|
+
bson (= 1.6.0)
|
|
45
45
|
builder (2.1.2)
|
|
46
|
-
columnize (0.3.
|
|
47
|
-
diff-lcs (1.1.
|
|
46
|
+
columnize (0.3.6)
|
|
47
|
+
diff-lcs (1.1.3)
|
|
48
48
|
erubis (2.6.6)
|
|
49
49
|
abstract (>= 1.0.0)
|
|
50
|
-
faraday (0.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
faraday (0.8.4)
|
|
51
|
+
multipart-post (~> 1.1)
|
|
52
|
+
httpauth (0.2.0)
|
|
53
|
+
i18n (0.6.0)
|
|
54
|
+
jwt (0.1.5)
|
|
55
|
+
multi_json (>= 1.0)
|
|
56
|
+
linecache19 (0.5.12)
|
|
56
57
|
ruby_core_source (>= 0.1.4)
|
|
57
|
-
mail (2.2.
|
|
58
|
+
mail (2.2.19)
|
|
58
59
|
activesupport (>= 2.3.6)
|
|
59
60
|
i18n (>= 0.4.0)
|
|
60
61
|
mime-types (~> 1.16)
|
|
61
62
|
treetop (~> 1.4.8)
|
|
62
|
-
mime-types (1.
|
|
63
|
-
mongo (1.
|
|
64
|
-
bson (
|
|
65
|
-
mongoid (2.
|
|
66
|
-
activemodel (~> 3.0)
|
|
63
|
+
mime-types (1.17.2)
|
|
64
|
+
mongo (1.6.0)
|
|
65
|
+
bson (= 1.6.0)
|
|
66
|
+
mongoid (2.2.6)
|
|
67
|
+
activemodel (~> 3.0.0)
|
|
67
68
|
mongo (~> 1.3)
|
|
68
69
|
tzinfo (~> 0.3.22)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
multi_json (1.1.0)
|
|
71
|
+
multipart-post (1.1.5)
|
|
72
|
+
oauth (0.4.7)
|
|
73
|
+
oauth2 (0.8.0)
|
|
74
|
+
faraday (~> 0.8)
|
|
75
|
+
httpauth (~> 0.1)
|
|
76
|
+
jwt (~> 0.1.4)
|
|
77
|
+
multi_json (~> 1.0)
|
|
78
|
+
rack (~> 1.2)
|
|
79
|
+
polyglot (0.3.3)
|
|
80
|
+
rack (1.2.5)
|
|
81
|
+
rack-mount (0.6.14)
|
|
79
82
|
rack (>= 1.0.0)
|
|
80
|
-
rack-test (0.5.
|
|
83
|
+
rack-test (0.5.7)
|
|
81
84
|
rack (>= 1.0)
|
|
82
85
|
rails (3.0.3)
|
|
83
86
|
actionmailer (= 3.0.3)
|
|
@@ -92,12 +95,12 @@ GEM
|
|
|
92
95
|
activesupport (= 3.0.3)
|
|
93
96
|
rake (>= 0.8.7)
|
|
94
97
|
thor (~> 0.14.4)
|
|
95
|
-
rake (0.
|
|
98
|
+
rake (0.9.2.2)
|
|
96
99
|
rspec (2.5.0)
|
|
97
100
|
rspec-core (~> 2.5.0)
|
|
98
101
|
rspec-expectations (~> 2.5.0)
|
|
99
102
|
rspec-mocks (~> 2.5.0)
|
|
100
|
-
rspec-core (2.5.
|
|
103
|
+
rspec-core (2.5.2)
|
|
101
104
|
rspec-expectations (2.5.0)
|
|
102
105
|
diff-lcs (~> 1.1.2)
|
|
103
106
|
rspec-mocks (2.5.0)
|
|
@@ -106,7 +109,7 @@ GEM
|
|
|
106
109
|
activesupport (~> 3.0)
|
|
107
110
|
railties (~> 3.0)
|
|
108
111
|
rspec (~> 2.5.0)
|
|
109
|
-
ruby-debug-base19 (0.11.
|
|
112
|
+
ruby-debug-base19 (0.11.25)
|
|
110
113
|
columnize (>= 0.3.1)
|
|
111
114
|
linecache19 (>= 0.5.11)
|
|
112
115
|
ruby_core_source (>= 0.1.4)
|
|
@@ -114,22 +117,24 @@ GEM
|
|
|
114
117
|
columnize (>= 0.3.1)
|
|
115
118
|
linecache19 (>= 0.5.11)
|
|
116
119
|
ruby-debug-base19 (>= 0.11.19)
|
|
117
|
-
ruby_core_source (0.1.
|
|
120
|
+
ruby_core_source (0.1.5)
|
|
118
121
|
archive-tar-minitar (>= 0.5.2)
|
|
119
|
-
simplecov (0.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
simplecov (0.6.1)
|
|
123
|
+
multi_json (~> 1.0)
|
|
124
|
+
simplecov-html (~> 0.5.3)
|
|
125
|
+
simplecov-html (0.5.3)
|
|
122
126
|
thor (0.14.6)
|
|
123
127
|
timecop (0.3.5)
|
|
124
|
-
treetop (1.4.
|
|
128
|
+
treetop (1.4.10)
|
|
129
|
+
polyglot
|
|
125
130
|
polyglot (>= 0.3.1)
|
|
126
|
-
tzinfo (0.3.
|
|
127
|
-
will_paginate (3.0.pre2)
|
|
131
|
+
tzinfo (0.3.31)
|
|
128
132
|
|
|
129
133
|
PLATFORMS
|
|
130
134
|
ruby
|
|
131
135
|
|
|
132
136
|
DEPENDENCIES
|
|
137
|
+
bcrypt-ruby (~> 3.0.0)
|
|
133
138
|
bson_ext (~> 1.3)
|
|
134
139
|
mongoid (~> 2.0)
|
|
135
140
|
rails (= 3.0.3)
|
|
@@ -16,6 +16,11 @@ class ApplicationController < ActionController::Base
|
|
|
16
16
|
render :nothing => true
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def some_action_making_a_non_persisted_change_to_the_user
|
|
20
|
+
current_user.username = "to_be_ignored"
|
|
21
|
+
render :nothing => true
|
|
22
|
+
end
|
|
23
|
+
|
|
19
24
|
def test_login
|
|
20
25
|
@user = login(params[:username], params[:password])
|
|
21
26
|
render :text => ""
|
|
@@ -101,6 +106,20 @@ class ApplicationController < ActionController::Base
|
|
|
101
106
|
end
|
|
102
107
|
end
|
|
103
108
|
|
|
109
|
+
def test_create_from_provider_with_block
|
|
110
|
+
provider = params[:provider]
|
|
111
|
+
login_from(provider)
|
|
112
|
+
@user = create_from(provider) do |user|
|
|
113
|
+
# check uniqueness of username
|
|
114
|
+
User.where(:username => user.username).empty?
|
|
115
|
+
end
|
|
116
|
+
if @user
|
|
117
|
+
redirect_to "bla", :notice => "Success!"
|
|
118
|
+
else
|
|
119
|
+
redirect_to "blu", :alert => "Failed!"
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
104
123
|
protected
|
|
105
124
|
|
|
106
125
|
|
|
File without changes
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe ApplicationController do
|
|
4
|
+
|
|
5
|
+
# ----------------- ACTIVITY LOGGING -----------------------
|
|
6
|
+
describe ApplicationController, "with activity logging features" do
|
|
7
|
+
before(:all) do
|
|
8
|
+
sorcery_reload!([:activity_logging])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
before(:each) do
|
|
12
|
+
create_new_user
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
after(:each) do
|
|
16
|
+
User.delete_all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
specify { subject.should respond_to(:current_users) }
|
|
20
|
+
|
|
21
|
+
it "'current_users' should be empty when no users are logged in" do
|
|
22
|
+
subject.current_users.size.should == 0
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should log login time on login" do
|
|
26
|
+
now = Time.now.utc
|
|
27
|
+
login_user
|
|
28
|
+
@user.last_login_at.should_not be_nil
|
|
29
|
+
@user.last_login_at.utc.to_s.should >= now.utc.to_s
|
|
30
|
+
@user.last_login_at.utc.to_s.should <= (now.utc+2).to_s
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should log logout time on logout" do
|
|
34
|
+
login_user
|
|
35
|
+
now = Time.now.utc
|
|
36
|
+
logout_user
|
|
37
|
+
User.first.last_logout_at.utc.should_not be_nil
|
|
38
|
+
User.first.last_logout_at.utc.to_s.should >= now.utc.to_s
|
|
39
|
+
User.first.last_logout_at.utc.to_s.should <= (now.utc+2).to_s
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should log last activity time when logged in" do
|
|
43
|
+
login_user
|
|
44
|
+
now = Time.now.utc
|
|
45
|
+
get :some_action
|
|
46
|
+
User.first.last_activity_at.utc.should >= now.utc
|
|
47
|
+
User.first.last_activity_at.utc.should <= (now.utc+2)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should update nothing but activity fields" do
|
|
51
|
+
original_user_name = User.first.username
|
|
52
|
+
login_user
|
|
53
|
+
get :some_action_making_a_non_persisted_change_to_the_user
|
|
54
|
+
User.first.username.should == original_user_name
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "'current_users' should hold the user object when 1 user is logged in" do
|
|
58
|
+
login_user
|
|
59
|
+
get :some_action
|
|
60
|
+
subject.current_users.size.should == 1
|
|
61
|
+
subject.current_users[0].should == @user
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "'current_users' should show all current_users, whether they have logged out before or not." do
|
|
65
|
+
user1 = create_new_user({:username => 'gizmo1', :email => "bla1@bla.com", :password => 'secret1'})
|
|
66
|
+
login_user(user1)
|
|
67
|
+
get :some_action
|
|
68
|
+
clear_user_without_logout
|
|
69
|
+
user2 = create_new_user({:username => 'gizmo2', :email => "bla2@bla.com", :password => 'secret2'})
|
|
70
|
+
login_user(user2)
|
|
71
|
+
get :some_action
|
|
72
|
+
clear_user_without_logout
|
|
73
|
+
user3 = create_new_user({:username => 'gizmo3', :email => "bla3@bla.com", :password => 'secret3'})
|
|
74
|
+
login_user(user3)
|
|
75
|
+
get :some_action
|
|
76
|
+
subject.current_users.size.should == 3
|
|
77
|
+
subject.current_users[0].should == user1
|
|
78
|
+
subject.current_users[1].should == user2
|
|
79
|
+
subject.current_users[2].should == user3
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should not register login time if configured so" do
|
|
83
|
+
sorcery_controller_property_set(:register_login_time, false)
|
|
84
|
+
now = Time.now.in_time_zone
|
|
85
|
+
login_user
|
|
86
|
+
@user.last_login_at.should be_nil
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should not register logout time if configured so" do
|
|
90
|
+
sorcery_controller_property_set(:register_logout_time, false)
|
|
91
|
+
now = Time.now.in_time_zone
|
|
92
|
+
login_user
|
|
93
|
+
logout_user
|
|
94
|
+
@user.last_logout_at.should be_nil
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should not register last activity time if configured so" do
|
|
98
|
+
sorcery_controller_property_set(:register_last_activity_time, false)
|
|
99
|
+
now = Time.now.in_time_zone
|
|
100
|
+
login_user
|
|
101
|
+
get :some_action
|
|
102
|
+
@user.last_activity_at.should be_nil
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -30,11 +30,16 @@ describe ApplicationController do
|
|
|
30
30
|
before(:all) do
|
|
31
31
|
sorcery_reload!
|
|
32
32
|
User.delete_all
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
before(:each) do
|
|
33
36
|
create_new_user
|
|
34
37
|
end
|
|
35
38
|
|
|
36
39
|
after(:each) do
|
|
37
40
|
Sorcery::Controller::Config.reset!
|
|
41
|
+
sorcery_reload!
|
|
42
|
+
User.delete_all
|
|
38
43
|
sorcery_controller_property_set(:user_class, User)
|
|
39
44
|
sorcery_model_property_set(:username_attribute_names, [:username, :email])
|
|
40
45
|
end
|
|
@@ -64,7 +69,35 @@ describe ApplicationController do
|
|
|
64
69
|
assigns[:user].should be_nil
|
|
65
70
|
session[:user_id].should be_nil
|
|
66
71
|
end
|
|
72
|
+
|
|
73
|
+
it "login(username,password) should return nil and not set the session when upper case username" do
|
|
74
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
|
75
|
+
assigns[:user].should be_nil
|
|
76
|
+
session[:user_id].should be_nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "login(username,password) should return the user and set the session with user.id when upper case username and config is downcase before authenticating" do
|
|
80
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
|
81
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
|
82
|
+
assigns[:user].should == @user
|
|
83
|
+
session[:user_id].should == @user.id
|
|
84
|
+
end
|
|
67
85
|
|
|
86
|
+
it "login(username,password) should return nil and not set the session when user was created with upper case username, config is default, and log in username is lower case" do
|
|
87
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
|
88
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
|
89
|
+
assigns[:user].should be_nil
|
|
90
|
+
session[:user_id].should be_nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "login(username,password) should return the user and set the session with user.id when user was created with upper case username and config is downcase before authenticating" do
|
|
94
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
|
95
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
|
96
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
|
97
|
+
assigns[:user].should == @user
|
|
98
|
+
session[:user_id].should == @user.id
|
|
99
|
+
end
|
|
100
|
+
|
|
68
101
|
it "logout should clear the session" do
|
|
69
102
|
cookies[:remember_me_token] = nil
|
|
70
103
|
session[:user_id] = @user.id
|
|
@@ -94,6 +127,17 @@ describe ApplicationController do
|
|
|
94
127
|
end
|
|
95
128
|
|
|
96
129
|
specify { should respond_to(:require_login) }
|
|
130
|
+
|
|
131
|
+
it "should call the configured 'not_authenticated_action' when session[:user_id] isn't found" do
|
|
132
|
+
# If someone passes in a bogus user_id than no big deal, but if a user is deleted
|
|
133
|
+
# and there is still an active session out there for him this causes problems.
|
|
134
|
+
user = User.create(:email => 'test@example.com', :password => 'password')
|
|
135
|
+
session[:user_id] = user.id
|
|
136
|
+
user.destroy
|
|
137
|
+
sorcery_controller_property_set(:not_authenticated_action, :test_not_authenticated_action)
|
|
138
|
+
get :test_logout
|
|
139
|
+
response.body.should == "test_not_authenticated_action"
|
|
140
|
+
end
|
|
97
141
|
|
|
98
142
|
it "should call the configured 'not_authenticated_action' when authenticate before_filter fails" do
|
|
99
143
|
session[:user_id] = nil
|
|
@@ -108,6 +152,13 @@ describe ApplicationController do
|
|
|
108
152
|
response.should redirect_to("http://test.host/")
|
|
109
153
|
end
|
|
110
154
|
|
|
155
|
+
it "require_login before_filter should not save the url that the user originally wanted upon all non-get http methods" do
|
|
156
|
+
[:post, :put, :delete].each do |m|
|
|
157
|
+
self.send(m, :some_action)
|
|
158
|
+
session[:return_to_url].should be_nil
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
111
162
|
it "on successful login the user should be redirected to the url he originally wanted" do
|
|
112
163
|
session[:return_to_url] = "http://test.host/some_action"
|
|
113
164
|
post :test_return_to, :username => 'gizmo', :password => 'secret'
|
|
@@ -127,4 +178,4 @@ describe ApplicationController do
|
|
|
127
178
|
end
|
|
128
179
|
end
|
|
129
180
|
|
|
130
|
-
end
|
|
181
|
+
end
|
|
@@ -32,6 +32,25 @@ shared_examples_for "oauth2_controller" do
|
|
|
32
32
|
end.should change(User, :count).by(1)
|
|
33
33
|
User.first.username.should == "Noam Ben Ari"
|
|
34
34
|
User.first.created_at.should_not be_nil
|
|
35
|
-
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "with a block" do
|
|
38
|
+
|
|
39
|
+
before(:each) do
|
|
40
|
+
user = User.new(:username => 'Noam Ben Ari')
|
|
41
|
+
user.save!(:validate => false)
|
|
42
|
+
user.authentications.create(:provider => 'twitter', :uid => '456')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should not create user" do
|
|
46
|
+
sorcery_model_property_set(:authentications_class, Authentication)
|
|
47
|
+
sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "name"})
|
|
48
|
+
lambda do
|
|
49
|
+
# test_create_from_provider_with_block in controller will check for uniqueness of username
|
|
50
|
+
get :test_create_from_provider_with_block, :provider => "facebook"
|
|
51
|
+
end.should_not change(User, :count)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
36
55
|
end
|
|
37
56
|
end
|
|
@@ -33,5 +33,23 @@ shared_examples_for "oauth_controller" do
|
|
|
33
33
|
User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
|
|
34
34
|
User.first.created_at.should_not be_nil
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
describe "with a block" do
|
|
38
|
+
|
|
39
|
+
before(:each) do
|
|
40
|
+
user = User.new(:username => 'nbenari')
|
|
41
|
+
user.save!(:validate => false)
|
|
42
|
+
user.authentications.create(:provider => 'github', :uid => '456')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should not create user" do
|
|
46
|
+
sorcery_model_property_set(:authentications_class, Authentication)
|
|
47
|
+
sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
|
|
48
|
+
lambda do
|
|
49
|
+
get :test_create_from_provider_with_block, :provider => "twitter"
|
|
50
|
+
end.should_not change(User, :count)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
36
54
|
end
|
|
37
55
|
end
|
|
@@ -34,9 +34,18 @@ shared_examples_for "rails_3_activation_model" do
|
|
|
34
34
|
sorcery_model_property_set(:activation_success_email_method_name, :my_activation_email)
|
|
35
35
|
User.sorcery_config.activation_success_email_method_name.should equal(:my_activation_email)
|
|
36
36
|
end
|
|
37
|
+
|
|
38
|
+
it "should enable configuration option 'activation_mailer_disabled'" do
|
|
39
|
+
sorcery_model_property_set(:activation_mailer_disabled, :my_activation_mailer_disabled)
|
|
40
|
+
User.sorcery_config.activation_mailer_disabled.should equal(:my_activation_mailer_disabled)
|
|
41
|
+
end
|
|
37
42
|
|
|
38
|
-
it "if mailer is nil
|
|
39
|
-
expect{sorcery_reload!([:user_activation])}.to raise_error(ArgumentError)
|
|
43
|
+
it "if mailer is nil and mailer is enabled, throw exception!" do
|
|
44
|
+
expect{sorcery_reload!([:user_activation], :activation_mailer_disabled => false)}.to raise_error(ArgumentError)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "if mailer is disabled and mailer is nil, do NOT throw exception" do
|
|
48
|
+
expect{sorcery_reload!([:user_activation], :activation_mailer_disabled => true)}.to_not raise_error
|
|
40
49
|
end
|
|
41
50
|
end
|
|
42
51
|
|
|
@@ -64,46 +73,67 @@ shared_examples_for "rails_3_activation_model" do
|
|
|
64
73
|
@user2.activation_state.should == "active"
|
|
65
74
|
User.find_by_activation_token(activation_token).should be_nil
|
|
66
75
|
end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
context "mailer is enabled" do
|
|
79
|
+
it "should send the user an activation email" do
|
|
80
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
81
|
+
create_new_user
|
|
82
|
+
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "subsequent saves do not send activation email" do
|
|
86
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
87
|
+
@user.username = "Shauli"
|
|
88
|
+
@user.save!
|
|
89
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should send the user an activation success email on successful activation" do
|
|
93
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
94
|
+
@user.activate!
|
|
95
|
+
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "subsequent saves do not send activation success email" do
|
|
99
|
+
@user.activate!
|
|
100
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
101
|
+
@user.username = "Shauli"
|
|
102
|
+
@user.save!
|
|
103
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "activation needed email is optional" do
|
|
107
|
+
sorcery_model_property_set(:activation_needed_email_method_name, nil)
|
|
108
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
109
|
+
create_new_user
|
|
110
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "activation success email is optional" do
|
|
114
|
+
sorcery_model_property_set(:activation_success_email_method_name, nil)
|
|
115
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
116
|
+
@user.activate!
|
|
117
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
118
|
+
end
|
|
100
119
|
end
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
120
|
+
|
|
121
|
+
context "mailer has been disabled" do
|
|
122
|
+
before(:each) do
|
|
123
|
+
sorcery_reload!([:user_activation], :activation_mailer_disabled => true, :user_activation_mailer => ::SorceryMailer)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "should not send the user an activation email" do
|
|
127
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
128
|
+
create_new_user
|
|
129
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "should not send the user an activation success email on successful activation" do
|
|
133
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
134
|
+
@user.activate!
|
|
135
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
136
|
+
end
|
|
107
137
|
end
|
|
108
138
|
end
|
|
109
139
|
|
|
@@ -155,7 +185,7 @@ shared_examples_for "rails_3_activation_model" do
|
|
|
155
185
|
it "load_from_activation_token should NOT return user when token is found and expired" do
|
|
156
186
|
sorcery_model_property_set(:activation_token_expiration_period, 0.1)
|
|
157
187
|
create_new_user
|
|
158
|
-
Timecop.travel(Time.now+0.5)
|
|
188
|
+
Timecop.travel(Time.now.in_time_zone+0.5)
|
|
159
189
|
User.load_from_activation_token(@user.activation_token).should == nil
|
|
160
190
|
end
|
|
161
191
|
|
|
@@ -34,7 +34,7 @@ shared_examples_for "rails_3_remember_me_model" do
|
|
|
34
34
|
it "should set an expiration based on 'remember_me_for' attribute" do
|
|
35
35
|
sorcery_model_property_set(:remember_me_for, 2 * 60 * 60 * 24)
|
|
36
36
|
@user.remember_me!
|
|
37
|
-
@user.remember_me_token_expires_at.utc.to_s.should == (Time.now + 2 * 60 * 60 * 24).utc.to_s
|
|
37
|
+
@user.remember_me_token_expires_at.utc.to_s.should == (Time.now.in_time_zone + 2 * 60 * 60 * 24).utc.to_s
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should delete the token and expiration on 'forget_me!'" do
|