sorcery 0.8.2 → 0.8.6
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.
- checksums.yaml +7 -0
- data/.gitignore +55 -0
- data/.travis.yml +69 -1
- data/CHANGELOG.md +248 -0
- data/Gemfile +16 -22
- data/Gemfile.rails4 +22 -0
- data/README.md +320 -0
- data/Rakefile +3 -79
- data/VERSION +1 -1
- data/gemfiles/active_record-rails41.gemfile +6 -0
- data/gemfiles/mongo_mapper-rails41.gemfile +8 -0
- data/gemfiles/mongoid-rails41.gemfile +11 -0
- data/lib/generators/sorcery/helpers.rb +40 -0
- data/lib/generators/sorcery/install_generator.rb +21 -17
- data/lib/generators/sorcery/templates/initializer.rb +1 -1
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +2 -11
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +1 -7
- data/lib/generators/sorcery/templates/migration/core.rb +5 -8
- data/lib/generators/sorcery/templates/migration/external.rb +1 -5
- data/lib/generators/sorcery/templates/migration/remember_me.rb +2 -9
- data/lib/generators/sorcery/templates/migration/reset_password.rb +2 -10
- data/lib/generators/sorcery/templates/migration/user_activation.rb +2 -10
- data/lib/sorcery/controller/submodules/external.rb +39 -20
- data/lib/sorcery/controller/submodules/remember_me.rb +1 -1
- data/lib/sorcery/controller/submodules/session_timeout.rb +2 -2
- data/lib/sorcery/controller.rb +18 -11
- data/lib/sorcery/model/adapters/active_record.rb +7 -2
- data/lib/sorcery/model/adapters/datamapper.rb +123 -0
- data/lib/sorcery/model/adapters/mongo_mapper.rb +8 -4
- data/lib/sorcery/model/adapters/mongoid.rb +8 -8
- data/lib/sorcery/model/submodules/activity_logging.rb +24 -0
- data/lib/sorcery/model/submodules/brute_force_protection.rb +22 -8
- data/lib/sorcery/model/submodules/remember_me.rb +19 -4
- data/lib/sorcery/model/submodules/reset_password.rb +35 -14
- data/lib/sorcery/model/submodules/user_activation.rb +69 -24
- data/lib/sorcery/model.rb +111 -73
- data/lib/sorcery/protocols/oauth.rb +42 -0
- data/lib/sorcery/protocols/oauth2.rb +47 -0
- data/lib/sorcery/providers/base.rb +27 -0
- data/lib/sorcery/providers/facebook.rb +63 -0
- data/lib/sorcery/providers/github.rb +51 -0
- data/lib/sorcery/providers/google.rb +51 -0
- data/lib/sorcery/providers/linkedin.rb +66 -0
- data/lib/sorcery/providers/liveid.rb +53 -0
- data/lib/sorcery/providers/twitter.rb +59 -0
- data/lib/sorcery/providers/vk.rb +61 -0
- data/lib/sorcery/providers/xing.rb +64 -0
- data/lib/sorcery/test_helpers/internal/rails.rb +17 -6
- data/lib/sorcery/test_helpers/internal.rb +23 -6
- data/lib/sorcery/test_helpers/rails/controller.rb +17 -0
- data/lib/sorcery/test_helpers/rails/integration.rb +26 -0
- data/lib/sorcery/test_helpers/rails.rb +1 -10
- data/lib/sorcery.rb +20 -28
- data/sorcery.gemspec +21 -363
- data/spec/active_record/controller_activity_logging_spec.rb +29 -0
- data/spec/active_record/controller_brute_force_protection_spec.rb +158 -0
- data/spec/active_record/controller_http_basic_auth_spec.rb +65 -0
- data/spec/active_record/controller_oauth2_spec.rb +342 -0
- data/spec/{rails3/spec → active_record}/controller_oauth_spec.rb +69 -59
- data/spec/active_record/controller_remember_me_spec.rb +97 -0
- data/spec/active_record/controller_session_timeout_spec.rb +70 -0
- data/spec/active_record/controller_spec.rb +8 -0
- data/spec/{rails3/spec → active_record}/integration_spec.rb +3 -3
- data/spec/active_record/user_activation_spec.rb +18 -0
- data/spec/active_record/user_activity_logging_spec.rb +8 -0
- data/spec/{rails3/spec → active_record}/user_brute_force_protection_spec.rb +6 -5
- data/spec/{rails3/spec → active_record}/user_oauth_spec.rb +6 -5
- data/spec/{rails3/spec → active_record}/user_remember_me_spec.rb +5 -4
- data/spec/{rails3/spec → active_record}/user_reset_password_spec.rb +7 -7
- data/spec/active_record/user_spec.rb +37 -0
- data/spec/datamapper/controller_activity_logging_spec.rb +17 -0
- data/spec/datamapper/controller_spec.rb +8 -0
- data/spec/datamapper/user_activation_spec.rb +10 -0
- data/spec/datamapper/user_activity_logging_spec.rb +9 -0
- data/spec/datamapper/user_brute_force_protection_spec.rb +9 -0
- data/spec/datamapper/user_oauth_spec.rb +9 -0
- data/spec/datamapper/user_remember_me_spec.rb +8 -0
- data/spec/datamapper/user_reset_password_spec.rb +8 -0
- data/spec/datamapper/user_spec.rb +27 -0
- data/spec/mongo_mapper/controller_spec.rb +8 -0
- data/spec/mongo_mapper/user_activation_spec.rb +9 -0
- data/spec/mongo_mapper/user_activity_logging_spec.rb +8 -0
- data/spec/mongo_mapper/user_brute_force_protection_spec.rb +8 -0
- data/spec/mongo_mapper/user_oauth_spec.rb +8 -0
- data/spec/mongo_mapper/user_remember_me_spec.rb +8 -0
- data/spec/mongo_mapper/user_reset_password_spec.rb +8 -0
- data/spec/mongo_mapper/user_spec.rb +37 -0
- data/spec/mongoid/controller_activity_logging_spec.rb +16 -0
- data/spec/mongoid/controller_spec.rb +8 -0
- data/spec/mongoid/user_activation_spec.rb +9 -0
- data/spec/mongoid/user_activity_logging_spec.rb +8 -0
- data/spec/mongoid/user_brute_force_protection_spec.rb +8 -0
- data/spec/mongoid/user_oauth_spec.rb +8 -0
- data/spec/mongoid/user_remember_me_spec.rb +8 -0
- data/spec/mongoid/user_reset_password_spec.rb +8 -0
- data/spec/mongoid/user_spec.rb +38 -0
- data/spec/orm/active_record.rb +9 -0
- data/spec/orm/datamapper.rb +34 -0
- data/spec/orm/mongo_mapper.rb +11 -0
- data/spec/orm/mongoid.rb +18 -0
- data/spec/{rails3/app/models → rails_app/app/active_record}/user.rb +1 -2
- data/spec/rails_app/app/active_record/user_provider.rb +3 -0
- data/spec/rails_app/app/controllers/sorcery_controller.rb +224 -0
- data/spec/rails_app/app/datamapper/authentication.rb +8 -0
- data/spec/rails_app/app/datamapper/user.rb +7 -0
- data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/user.rb +2 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config/application.rb +13 -8
- data/spec/rails_app/config/boot.rb +4 -0
- data/spec/rails_app/config/database.yml +22 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config/environments/test.rb +2 -0
- data/spec/{rails3_mongoid → rails_app}/config/initializers/session_store.rb +4 -0
- data/spec/rails_app/config/routes.rb +42 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config.ru +1 -1
- data/spec/{rails3 → rails_app}/db/migrate/activation/20101224223622_add_activation_to_users.rb +3 -3
- data/spec/rails_app/db/migrate/external/20101224223628_create_authentications_and_user_providers.rb +22 -0
- data/spec/rails_app/log/development.log +1791 -0
- data/spec/shared_examples/controller_activity_logging_shared_examples.rb +125 -0
- data/spec/shared_examples/controller_oauth2_shared_examples.rb +32 -36
- data/spec/shared_examples/controller_oauth_shared_examples.rb +35 -28
- data/spec/shared_examples/controller_shared_examples.rb +203 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +136 -97
- data/spec/shared_examples/user_activity_logging_shared_examples.rb +10 -10
- data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +14 -13
- data/spec/shared_examples/user_oauth_shared_examples.rb +23 -15
- data/spec/shared_examples/user_remember_me_shared_examples.rb +32 -23
- data/spec/shared_examples/user_reset_password_shared_examples.rb +162 -129
- data/spec/shared_examples/user_shared_examples.rb +265 -190
- data/spec/sorcery_crypto_providers_spec.rb +74 -72
- data/spec/spec_helper.rb +47 -4
- metadata +277 -501
- data/Gemfile.lock +0 -175
- data/README.rdoc +0 -261
- data/lib/sorcery/controller/submodules/external/protocols/oauth1.rb +0 -46
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +0 -49
- data/lib/sorcery/controller/submodules/external/providers/base.rb +0 -21
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +0 -98
- data/lib/sorcery/controller/submodules/external/providers/github.rb +0 -92
- data/lib/sorcery/controller/submodules/external/providers/google.rb +0 -91
- data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +0 -102
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +0 -92
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +0 -93
- data/lib/sorcery/controller/submodules/external/providers/vk.rb +0 -100
- data/lib/sorcery/controller/submodules/external/providers/xing.rb +0 -97
- data/lib/sorcery/test_helpers.rb +0 -5
- data/spec/Gemfile +0 -12
- data/spec/Gemfile.lock +0 -129
- data/spec/README.md +0 -31
- data/spec/Rakefile +0 -12
- data/spec/rails3/.gitignore +0 -4
- data/spec/rails3/.rspec +0 -1
- data/spec/rails3/Gemfile +0 -15
- data/spec/rails3/Gemfile.lock +0 -162
- data/spec/rails3/README +0 -256
- data/spec/rails3/Rakefile +0 -11
- data/spec/rails3/app/controllers/application_controller.rb +0 -208
- data/spec/rails3/config/application.rb +0 -46
- data/spec/rails3/config/boot.rb +0 -13
- data/spec/rails3/config/database.yml +0 -27
- data/spec/rails3/config/environments/development.rb +0 -26
- data/spec/rails3/config/environments/in_memory.rb +0 -35
- data/spec/rails3/config/environments/production.rb +0 -49
- data/spec/rails3/config/environments/test.rb +0 -35
- data/spec/rails3/config/initializers/session_store.rb +0 -8
- data/spec/rails3/config/routes.rb +0 -59
- data/spec/rails3/config.ru +0 -4
- data/spec/rails3/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/rails3/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3/script/rails +0 -6
- data/spec/rails3/spec/controller_activity_logging_spec.rb +0 -130
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +0 -96
- data/spec/rails3/spec/controller_http_basic_auth_spec.rb +0 -50
- data/spec/rails3/spec/controller_oauth2_spec.rb +0 -380
- data/spec/rails3/spec/controller_remember_me_spec.rb +0 -96
- data/spec/rails3/spec/controller_session_timeout_spec.rb +0 -55
- data/spec/rails3/spec/controller_spec.rb +0 -182
- data/spec/rails3/spec/spec.opts +0 -2
- data/spec/rails3/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3/spec/spec_helper.rb +0 -71
- data/spec/rails3/spec/user_activation_spec.rb +0 -16
- data/spec/rails3/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3/spec/user_spec.rb +0 -36
- data/spec/rails3/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/.gitignore +0 -4
- data/spec/rails3_mongo_mapper/.rspec +0 -1
- data/spec/rails3_mongo_mapper/Gemfile +0 -16
- data/spec/rails3_mongo_mapper/Gemfile.lock +0 -156
- data/spec/rails3_mongo_mapper/Rakefile +0 -11
- data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +0 -122
- data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +0 -2
- data/spec/rails3_mongo_mapper/app/mailers/sorcery_mailer.rb +0 -25
- data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +0 -14
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +0 -17
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +0 -9
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
- data/spec/rails3_mongo_mapper/config/boot.rb +0 -13
- data/spec/rails3_mongo_mapper/config/environment.rb +0 -5
- data/spec/rails3_mongo_mapper/config/environments/development.rb +0 -30
- data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongo_mapper/config/environments/production.rb +0 -49
- data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +0 -10
- data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +0 -5
- data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +0 -2
- data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +0 -7
- data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +0 -8
- data/spec/rails3_mongo_mapper/config/locales/en.yml +0 -5
- data/spec/rails3_mongo_mapper/config/routes.rb +0 -59
- data/spec/rails3_mongo_mapper/db/schema.rb +0 -23
- data/spec/rails3_mongo_mapper/db/seeds.rb +0 -7
- data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/public/404.html +0 -26
- data/spec/rails3_mongo_mapper/public/422.html +0 -26
- data/spec/rails3_mongo_mapper/public/500.html +0 -26
- 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 +0 -2
- data/spec/rails3_mongo_mapper/public/javascripts/controls.js +0 -965
- data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3_mongo_mapper/public/javascripts/effects.js +0 -1123
- data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +0 -6001
- data/spec/rails3_mongo_mapper/public/javascripts/rails.js +0 -175
- data/spec/rails3_mongo_mapper/public/robots.txt +0 -5
- data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/script/rails +0 -6
- data/spec/rails3_mongo_mapper/spec/controller_spec.rb +0 -175
- data/spec/rails3_mongo_mapper/spec/spec.opts +0 -2
- data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3_mongo_mapper/spec/spec_helper.rb +0 -55
- data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +0 -9
- data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_spec.rb +0 -37
- data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongoid/.gitignore +0 -4
- data/spec/rails3_mongoid/.rspec +0 -1
- data/spec/rails3_mongoid/Gemfile +0 -15
- data/spec/rails3_mongoid/Gemfile.lock +0 -146
- data/spec/rails3_mongoid/Rakefile +0 -11
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +0 -127
- data/spec/rails3_mongoid/app/helpers/application_helper.rb +0 -2
- data/spec/rails3_mongoid/app/mailers/sorcery_mailer.rb +0 -25
- data/spec/rails3_mongoid/app/views/layouts/application.html.erb +0 -14
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.html.erb +0 -17
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.text.erb +0 -9
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.html.erb +0 -17
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
- data/spec/rails3_mongoid/config/application.rb +0 -51
- data/spec/rails3_mongoid/config/boot.rb +0 -13
- data/spec/rails3_mongoid/config/environment.rb +0 -5
- data/spec/rails3_mongoid/config/environments/development.rb +0 -26
- data/spec/rails3_mongoid/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongoid/config/environments/production.rb +0 -49
- data/spec/rails3_mongoid/config/environments/test.rb +0 -35
- data/spec/rails3_mongoid/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails3_mongoid/config/initializers/inflections.rb +0 -10
- data/spec/rails3_mongoid/config/initializers/mime_types.rb +0 -5
- data/spec/rails3_mongoid/config/initializers/secret_token.rb +0 -7
- data/spec/rails3_mongoid/config/locales/en.yml +0 -5
- data/spec/rails3_mongoid/config/mongoid.yml +0 -7
- data/spec/rails3_mongoid/config/routes.rb +0 -59
- data/spec/rails3_mongoid/config.ru +0 -4
- data/spec/rails3_mongoid/db/schema.rb +0 -23
- data/spec/rails3_mongoid/db/seeds.rb +0 -7
- data/spec/rails3_mongoid/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongoid/public/404.html +0 -26
- data/spec/rails3_mongoid/public/422.html +0 -26
- data/spec/rails3_mongoid/public/500.html +0 -26
- data/spec/rails3_mongoid/public/favicon.ico +0 -0
- data/spec/rails3_mongoid/public/images/rails.png +0 -0
- data/spec/rails3_mongoid/public/javascripts/application.js +0 -2
- data/spec/rails3_mongoid/public/javascripts/controls.js +0 -965
- data/spec/rails3_mongoid/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3_mongoid/public/javascripts/effects.js +0 -1123
- data/spec/rails3_mongoid/public/javascripts/prototype.js +0 -6001
- data/spec/rails3_mongoid/public/javascripts/rails.js +0 -175
- data/spec/rails3_mongoid/public/robots.txt +0 -5
- data/spec/rails3_mongoid/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongoid/script/rails +0 -6
- data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +0 -111
- data/spec/rails3_mongoid/spec/controller_spec.rb +0 -186
- data/spec/rails3_mongoid/spec/spec.opts +0 -2
- data/spec/rails3_mongoid/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3_mongoid/spec/spec_helper.rb +0 -55
- data/spec/rails3_mongoid/spec/user_activation_spec.rb +0 -9
- data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_oauth_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_spec.rb +0 -38
- data/spec/rails3_mongoid/vendor/plugins/.gitkeep +0 -0
- /data/lib/sorcery/{controller/submodules/external/protocols → protocols}/certs/ca-bundle.crt +0 -0
- /data/spec/{rails3/app/models → rails_app/app/active_record}/authentication.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/helpers/application_helper.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/mailers/sorcery_mailer.rb +0 -0
- /data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/authentication.rb +0 -0
- /data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/user.rb +0 -0
- /data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/authentication.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/application/index.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/layouts/application.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_email.text.erb +0 -0
- /data/spec/{rails3/app/views/sorcery_mailer/activation_success_email.html.erb → rails_app/app/views/sorcery_mailer/activation_needed_email.html.erb} +0 -0
- /data/spec/{rails3_mongo_mapper → rails_app}/app/views/sorcery_mailer/activation_success_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_success_email.text.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/reset_password_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/reset_password_email.text.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/send_unlock_token_email.text.erb +0 -0
- /data/spec/{rails3 → rails_app}/config/environment.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/backtrace_silencers.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/inflections.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/mime_types.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/secret_token.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/locales/en.yml +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/core/20101224223620_create_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/schema.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/seeds.rb +0 -0
- /data/spec/{rails3 → rails_app}/public/404.html +0 -0
- /data/spec/{rails3 → rails_app}/public/422.html +0 -0
- /data/spec/{rails3 → rails_app}/public/500.html +0 -0
- /data/spec/{rails3 → rails_app}/public/favicon.ico +0 -0
- /data/spec/{rails3 → rails_app}/public/images/rails.png +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/application.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/controls.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/dragdrop.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/effects.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/prototype.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/rails.js +0 -0
- /data/spec/{rails3 → rails_app}/public/robots.txt +0 -0
- /data/spec/{rails3/lib/tasks → rails_app/public/stylesheets}/.gitkeep +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
shared_examples_for "controller_activity_logging" do
|
|
2
|
+
|
|
3
|
+
before(:all) do
|
|
4
|
+
sorcery_reload!([:activity_logging])
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
specify { expect(subject).to respond_to(:current_users) }
|
|
8
|
+
let(:user) { create_new_user }
|
|
9
|
+
|
|
10
|
+
before(:each) { user }
|
|
11
|
+
|
|
12
|
+
it "'current_users' is empty when no users are logged in" do
|
|
13
|
+
expect(subject.current_users.size).to eq 0
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "logs login time on login" do
|
|
17
|
+
now = Time.now.in_time_zone
|
|
18
|
+
login_user
|
|
19
|
+
|
|
20
|
+
expect(user.last_login_at).not_to be_nil
|
|
21
|
+
expect(user.last_login_at.utc.to_s).to be >= now.utc.to_s
|
|
22
|
+
expect(user.last_login_at.utc.to_s).to be <= (now.utc+2).to_s
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "logs logout time on logout" do
|
|
26
|
+
login_user
|
|
27
|
+
now = Time.now.in_time_zone
|
|
28
|
+
logout_user
|
|
29
|
+
|
|
30
|
+
expect(User.last.last_logout_at).not_to be_nil
|
|
31
|
+
|
|
32
|
+
expect(User.last.last_logout_at.utc.to_s).to be >= now.utc.to_s
|
|
33
|
+
expect(User.last.last_logout_at.utc.to_s).to be <= (now+2).utc.to_s
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "logs last activity time when logged in" do
|
|
37
|
+
sorcery_controller_property_set(:register_last_activity_time, true)
|
|
38
|
+
|
|
39
|
+
login_user
|
|
40
|
+
now = Time.now.in_time_zone
|
|
41
|
+
get :some_action
|
|
42
|
+
|
|
43
|
+
last_activity_at = User.last.last_activity_at
|
|
44
|
+
|
|
45
|
+
expect(last_activity_at).to be_present
|
|
46
|
+
expect(last_activity_at.utc.to_s).to be >= now.utc.to_s
|
|
47
|
+
expect(last_activity_at.utc.to_s).to be <= (now+2).utc.to_s
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "logs last IP address when logged in" do
|
|
51
|
+
login_user
|
|
52
|
+
get :some_action
|
|
53
|
+
|
|
54
|
+
expect(User.last.last_login_from_ip_address).to eq "0.0.0.0"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "updates nothing but activity fields" do
|
|
58
|
+
original_user_name = User.last.username
|
|
59
|
+
login_user
|
|
60
|
+
get :some_action_making_a_non_persisted_change_to_the_user
|
|
61
|
+
|
|
62
|
+
expect(User.last.username).to eq original_user_name
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "'current_users' holds the user object when 1 user is logged in" do
|
|
66
|
+
login_user
|
|
67
|
+
get :some_action
|
|
68
|
+
|
|
69
|
+
expect(subject.current_users).to match([User.find(user.id)])
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "'current_users' shows all current_users, whether they have logged out before or not." do
|
|
73
|
+
user1 = create_new_user({:username => 'gizmo1', :email => "bla1@bla.com", :password => 'secret1'})
|
|
74
|
+
login_user(user1)
|
|
75
|
+
get :some_action
|
|
76
|
+
clear_user_without_logout
|
|
77
|
+
user2 = create_new_user({:username => 'gizmo2', :email => "bla2@bla.com", :password => 'secret2'})
|
|
78
|
+
login_user(user2)
|
|
79
|
+
get :some_action
|
|
80
|
+
clear_user_without_logout
|
|
81
|
+
user3 = create_new_user({:username => 'gizmo3', :email => "bla3@bla.com", :password => 'secret3'})
|
|
82
|
+
login_user(user3)
|
|
83
|
+
get :some_action
|
|
84
|
+
|
|
85
|
+
expect(subject.current_users.size).to eq 3
|
|
86
|
+
expect(subject.current_users[0]).to eq User.find(user1.id)
|
|
87
|
+
expect(subject.current_users[1]).to eq User.find(user2.id)
|
|
88
|
+
expect(subject.current_users[2]).to eq User.find(user3.id)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "does not register login time if configured so" do
|
|
92
|
+
sorcery_controller_property_set(:register_login_time, false)
|
|
93
|
+
now = Time.now.in_time_zone
|
|
94
|
+
login_user
|
|
95
|
+
|
|
96
|
+
expect(user.last_login_at).to be_nil
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "does not register logout time if configured so" do
|
|
100
|
+
sorcery_controller_property_set(:register_logout_time, false)
|
|
101
|
+
now = Time.now.in_time_zone
|
|
102
|
+
login_user
|
|
103
|
+
logout_user
|
|
104
|
+
|
|
105
|
+
expect(user.last_logout_at).to be_nil
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "does not register last activity time if configured so" do
|
|
109
|
+
sorcery_controller_property_set(:register_last_activity_time, false)
|
|
110
|
+
now = Time.now.in_time_zone
|
|
111
|
+
login_user
|
|
112
|
+
get :some_action
|
|
113
|
+
|
|
114
|
+
expect(user.last_activity_at).to be_nil
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "does not register last IP address if configured so" do
|
|
118
|
+
sorcery_controller_property_set(:register_last_ip_address, false)
|
|
119
|
+
ip_address = "127.0.0.1"
|
|
120
|
+
login_user
|
|
121
|
+
get :some_action
|
|
122
|
+
|
|
123
|
+
expect(user.last_activity_at).to be_nil
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -1,56 +1,52 @@
|
|
|
1
|
-
shared_examples_for
|
|
2
|
-
describe
|
|
1
|
+
shared_examples_for 'oauth2_controller' do
|
|
2
|
+
describe 'using create_from' do
|
|
3
3
|
before(:each) do
|
|
4
4
|
stub_all_oauth2_requests!
|
|
5
5
|
User.delete_all
|
|
6
6
|
Authentication.delete_all
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
it
|
|
9
|
+
it 'creates a new user' do
|
|
10
10
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
11
|
-
sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
User.first.username.should == "Noam Ben Ari"
|
|
11
|
+
sorcery_controller_external_property_set(:facebook, :user_info_mapping, { username: 'name' })
|
|
12
|
+
|
|
13
|
+
expect { get :test_create_from_provider, provider: 'facebook' }.to change { User.count }.by 1
|
|
14
|
+
expect(User.first.username).to eq 'Noam Ben Ari'
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
it
|
|
17
|
+
it 'supports nested attributes' do
|
|
19
18
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
20
|
-
sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
User.first.username.should == "Haifa, Israel"
|
|
19
|
+
sorcery_controller_external_property_set(:facebook, :user_info_mapping, { username: 'hometown/name' })
|
|
20
|
+
|
|
21
|
+
expect { get :test_create_from_provider, provider: 'facebook' }.to change { User.count }.by(1)
|
|
22
|
+
expect(User.first.username).to eq 'Haifa, Israel'
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
it
|
|
25
|
+
it 'does not crash on missing nested attributes' do
|
|
28
26
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
29
|
-
sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
User.first.
|
|
34
|
-
User.first.created_at.should_not be_nil
|
|
27
|
+
sorcery_controller_external_property_set(:facebook, :user_info_mapping, { username: 'name', created_at: 'does/not/exist' })
|
|
28
|
+
|
|
29
|
+
expect { get :test_create_from_provider, provider: 'facebook' }.to change { User.count }.by 1
|
|
30
|
+
expect(User.first.username).to eq 'Noam Ben Ari'
|
|
31
|
+
expect(User.first.created_at).not_to be_nil
|
|
35
32
|
end
|
|
36
|
-
|
|
37
|
-
describe
|
|
38
|
-
|
|
33
|
+
|
|
34
|
+
describe 'with a block' do
|
|
35
|
+
|
|
39
36
|
before(:each) do
|
|
40
|
-
user = User.new(:
|
|
41
|
-
user.save!(:
|
|
42
|
-
user.authentications.create(:
|
|
37
|
+
user = User.new(username: 'Noam Ben Ari')
|
|
38
|
+
user.save!(validate: false)
|
|
39
|
+
user.authentications.create(provider: 'twitter', uid: '456')
|
|
43
40
|
end
|
|
44
|
-
|
|
45
|
-
it
|
|
41
|
+
|
|
42
|
+
it 'does not create user' do
|
|
46
43
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
47
|
-
sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
end.should_not change(User, :count)
|
|
44
|
+
sorcery_controller_external_property_set(:facebook, :user_info_mapping, { username: 'name' })
|
|
45
|
+
|
|
46
|
+
# test_create_from_provider_with_block in controller will check for uniqueness of username
|
|
47
|
+
expect { get :test_create_from_provider_with_block, provider: 'facebook' }.not_to change { User.count }
|
|
52
48
|
end
|
|
53
|
-
|
|
49
|
+
|
|
54
50
|
end
|
|
55
51
|
end
|
|
56
|
-
end
|
|
52
|
+
end
|
|
@@ -5,51 +5,58 @@ shared_examples_for "oauth_controller" do
|
|
|
5
5
|
User.delete_all
|
|
6
6
|
Authentication.delete_all
|
|
7
7
|
end
|
|
8
|
-
|
|
9
|
-
it "
|
|
8
|
+
|
|
9
|
+
it "creates a new user" do
|
|
10
10
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
11
11
|
sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
User.first.username.should == "nbenari"
|
|
12
|
+
|
|
13
|
+
expect { get :test_create_from_provider, :provider => "twitter" }.to change { User.count }.by 1
|
|
14
|
+
expect(User.first.username).to eq "nbenari"
|
|
16
15
|
end
|
|
17
|
-
|
|
18
|
-
it "
|
|
16
|
+
|
|
17
|
+
it "supports nested attributes" do
|
|
19
18
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
20
19
|
sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
|
|
20
|
+
|
|
21
|
+
expect { get :test_create_from_provider, :provider => "twitter" }.to change { User.count }.by 1
|
|
22
|
+
expect(User.first.username).to eq "coming soon to sorcery gem: twitter and facebook authentication support."
|
|
25
23
|
end
|
|
26
|
-
|
|
27
|
-
it "
|
|
24
|
+
|
|
25
|
+
it "does not crash on missing nested attributes" do
|
|
28
26
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
29
27
|
sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text", :created_at => "does/not/exist"})
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
User.first.
|
|
34
|
-
User.first.created_at.should_not be_nil
|
|
28
|
+
|
|
29
|
+
expect { get :test_create_from_provider, :provider => "twitter" }.to change { User.count }.by 1
|
|
30
|
+
expect(User.first.username).to eq "coming soon to sorcery gem: twitter and facebook authentication support."
|
|
31
|
+
expect(User.first.created_at).not_to be_nil
|
|
35
32
|
end
|
|
36
|
-
|
|
33
|
+
|
|
34
|
+
it "binds new provider" do
|
|
35
|
+
sorcery_model_property_set(:authentications_class, UserProvider)
|
|
36
|
+
|
|
37
|
+
current_user = custom_create_new_external_user(:facebook, UserProvider)
|
|
38
|
+
login_user(current_user)
|
|
39
|
+
|
|
40
|
+
expect { get :test_add_second_provider, :provider => "twitter" }.to change { UserProvider.count }.by 1
|
|
41
|
+
expect(UserProvider.where(:user_id => current_user.id).size).to eq 2
|
|
42
|
+
expect(User.count).to eq 1
|
|
43
|
+
end
|
|
44
|
+
|
|
37
45
|
describe "with a block" do
|
|
38
|
-
|
|
46
|
+
|
|
39
47
|
before(:each) do
|
|
40
48
|
user = User.new(:username => 'nbenari')
|
|
41
49
|
user.save!(:validate => false)
|
|
42
50
|
user.authentications.create(:provider => 'github', :uid => '456')
|
|
43
51
|
end
|
|
44
|
-
|
|
45
|
-
it "
|
|
52
|
+
|
|
53
|
+
it "does not create user" do
|
|
46
54
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
47
55
|
sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
end.should_not change(User, :count)
|
|
56
|
+
|
|
57
|
+
expect { get :test_create_from_provider_with_block, :provider => "twitter" }.not_to change { User.count }
|
|
51
58
|
end
|
|
52
|
-
|
|
59
|
+
|
|
53
60
|
end
|
|
54
61
|
end
|
|
55
|
-
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
shared_examples_for "sorcery_controller" do
|
|
2
|
+
|
|
3
|
+
describe "plugin configuration" do
|
|
4
|
+
before(:all) do
|
|
5
|
+
sorcery_reload!
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
after(:each) do
|
|
9
|
+
Sorcery::Controller::Config.reset!
|
|
10
|
+
sorcery_reload!
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "enables configuration option 'user_class'" do
|
|
14
|
+
sorcery_controller_property_set(:user_class, "TestUser")
|
|
15
|
+
|
|
16
|
+
expect(Sorcery::Controller::Config.user_class).to eq "TestUser"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "enables configuration option 'not_authenticated_action'" do
|
|
20
|
+
sorcery_controller_property_set(:not_authenticated_action, :my_action)
|
|
21
|
+
|
|
22
|
+
expect(Sorcery::Controller::Config.not_authenticated_action).to eq :my_action
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# ----------------- PLUGIN ACTIVATED -----------------------
|
|
28
|
+
context "when activated with sorcery" do
|
|
29
|
+
let!(:user) { create_new_user }
|
|
30
|
+
|
|
31
|
+
before(:all) do
|
|
32
|
+
sorcery_reload!
|
|
33
|
+
User.delete_all
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
after(:each) do
|
|
37
|
+
Sorcery::Controller::Config.reset!
|
|
38
|
+
sorcery_reload!
|
|
39
|
+
User.delete_all
|
|
40
|
+
sorcery_controller_property_set(:user_class, User)
|
|
41
|
+
sorcery_model_property_set(:username_attribute_names, [:email])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
specify { should respond_to(:login) }
|
|
45
|
+
|
|
46
|
+
specify { should respond_to(:logout) }
|
|
47
|
+
|
|
48
|
+
specify { should respond_to(:logged_in?) }
|
|
49
|
+
|
|
50
|
+
specify { should respond_to(:current_user) }
|
|
51
|
+
|
|
52
|
+
it "login(username,password) returns the user when success and set the session with user.id" do
|
|
53
|
+
get :test_login, :email => 'bla@bla.com', :password => 'secret'
|
|
54
|
+
|
|
55
|
+
expect(assigns[:user]).to eq user
|
|
56
|
+
expect(session[:user_id]).to eq user.id
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "login(email,password) returns the user when success and set the session with user.id" do
|
|
60
|
+
get :test_login, :email => 'bla@bla.com', :password => 'secret'
|
|
61
|
+
|
|
62
|
+
expect(assigns[:user]).to eq user
|
|
63
|
+
expect(session[:user_id]).to eq user.id
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "login(username,password) returns nil and not set the session when failure" do
|
|
67
|
+
get :test_login, :email => 'bla@bla.com', :password => 'opensesame!'
|
|
68
|
+
|
|
69
|
+
expect(assigns[:user]).to be_nil
|
|
70
|
+
expect(session[:user_id]).to be_nil
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "login(email,password) returns the user when success and set the session with the _csrf_token" do
|
|
74
|
+
get :test_login, :email => 'bla@bla.com', :password => 'secret'
|
|
75
|
+
|
|
76
|
+
expect(session[:_csrf_token]).not_to be_nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "login(username,password) returns nil and not set the session when upper case username" do
|
|
80
|
+
skip('DM Adapter dependant') if SORCERY_ORM == :datamapper
|
|
81
|
+
get :test_login, :email => 'BLA@BLA.COM', :password => 'secret'
|
|
82
|
+
|
|
83
|
+
expect(assigns[:user]).to be_nil
|
|
84
|
+
expect(session[:user_id]).to be_nil
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "login(username,password) returns the user and set the session with user.id when upper case username and config is downcase before authenticating" do
|
|
88
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
|
89
|
+
get :test_login, :email => 'BLA@BLA.COM', :password => 'secret'
|
|
90
|
+
|
|
91
|
+
expect(assigns[:user]).to eq user
|
|
92
|
+
expect(session[:user_id]).to eq user.id
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "login(username,password) returns 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
|
|
96
|
+
skip('DM Adapter dependant') if SORCERY_ORM == :datamapper
|
|
97
|
+
create_new_user({:username => "", :email => "BLA1@BLA.COM", :password => 'secret1'})
|
|
98
|
+
get :test_login, :email => 'bla1@bla.com', :password => 'secret1'
|
|
99
|
+
|
|
100
|
+
expect(assigns[:user]).to be_nil
|
|
101
|
+
expect(session[:user_id]).to be_nil
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "login(username,password) returns the user and set the session with user.id when user was created with upper case username and config is downcase before authenticating" do
|
|
105
|
+
skip('DM Adapter dependant') if SORCERY_ORM == :datamapper
|
|
106
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
|
107
|
+
new_user = create_new_user({:username => "", :email => "BLA1@BLA.COM", :password => 'secret1'})
|
|
108
|
+
get :test_login, :email => 'bla1@bla.com', :password => 'secret1'
|
|
109
|
+
|
|
110
|
+
expect(assigns[:user]).to eq new_user
|
|
111
|
+
expect(session[:user_id]).to eq new_user.id
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "logout clears the session" do
|
|
115
|
+
cookies[:remember_me_token] = nil
|
|
116
|
+
session[:user_id] = user.id
|
|
117
|
+
get :test_logout
|
|
118
|
+
|
|
119
|
+
expect(session[:user_id]).to be_nil
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "logged_in? returns true if logged in" do
|
|
123
|
+
session[:user_id] = user.id
|
|
124
|
+
|
|
125
|
+
expect(subject.logged_in?).to be true
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "logged_in? returns false if not logged in" do
|
|
129
|
+
session[:user_id] = nil
|
|
130
|
+
|
|
131
|
+
expect(subject.logged_in?).to be false
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "current_user returns the user instance if logged in" do
|
|
135
|
+
create_new_user
|
|
136
|
+
session[:user_id] = user.id
|
|
137
|
+
|
|
138
|
+
2.times { expect(subject.current_user).to eq user } # memoized!
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "current_user returns false if not logged in" do
|
|
142
|
+
session[:user_id] = nil
|
|
143
|
+
|
|
144
|
+
2.times { expect(subject.current_user).to be_nil } # memoized!
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
specify { should respond_to(:require_login) }
|
|
148
|
+
|
|
149
|
+
it "calls the configured 'not_authenticated_action' when authenticate before_filter fails" do
|
|
150
|
+
session[:user_id] = nil
|
|
151
|
+
sorcery_controller_property_set(:not_authenticated_action, :test_not_authenticated_action)
|
|
152
|
+
get :test_logout
|
|
153
|
+
|
|
154
|
+
expect(response.body).to eq "test_not_authenticated_action"
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "require_login before_filter saves the url that the user originally wanted" do
|
|
158
|
+
get :some_action
|
|
159
|
+
|
|
160
|
+
expect(session[:return_to_url]).to eq "http://test.host/some_action"
|
|
161
|
+
expect(response).to redirect_to("http://test.host/")
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it "require_login before_filter does not save the url that the user originally wanted upon all non-get http methods" do
|
|
165
|
+
[:post, :put, :delete].each do |m|
|
|
166
|
+
self.send(m, :some_action)
|
|
167
|
+
|
|
168
|
+
expect(session[:return_to_url]).to be_nil
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it "on successful login the user is redirected to the url he originally wanted" do
|
|
173
|
+
session[:return_to_url] = "http://test.host/some_action"
|
|
174
|
+
post :test_return_to, :email => 'bla@bla.com', :password => 'secret'
|
|
175
|
+
|
|
176
|
+
expect(response).to redirect_to("http://test.host/some_action")
|
|
177
|
+
expect(flash[:notice]).to eq "haha!"
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
# --- auto_login(user) ---
|
|
182
|
+
specify { should respond_to(:auto_login) }
|
|
183
|
+
|
|
184
|
+
it "auto_login(user) los in a user instance" do
|
|
185
|
+
session[:user_id] = nil
|
|
186
|
+
subject.auto_login(user)
|
|
187
|
+
|
|
188
|
+
expect(subject.logged_in?).to be true
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "auto_login(user) works even if current_user was already set to false" do
|
|
192
|
+
get :test_logout
|
|
193
|
+
|
|
194
|
+
expect(session[:user_id]).to be_nil
|
|
195
|
+
expect(subject.current_user).to be_nil
|
|
196
|
+
|
|
197
|
+
get :test_auto_login
|
|
198
|
+
|
|
199
|
+
expect(assigns[:result]).to eq User.first
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
end
|