sorcery 0.8.1 → 0.9.1
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 +56 -0
- data/.travis.yml +130 -1
- data/CHANGELOG.md +279 -0
- data/Gemfile +18 -23
- data/README.md +372 -0
- data/Rakefile +3 -78
- data/gemfiles/active_record-rails40.gemfile +7 -0
- data/gemfiles/active_record-rails41.gemfile +7 -0
- data/gemfiles/mongo_mapper-rails40.gemfile +9 -0
- data/gemfiles/mongo_mapper-rails41.gemfile +9 -0
- data/gemfiles/mongoid-rails40.gemfile +9 -0
- data/gemfiles/mongoid-rails41.gemfile +9 -0
- data/gemfiles/mongoid3-rails32.gemfile +9 -0
- data/lib/generators/sorcery/USAGE +1 -1
- data/lib/generators/sorcery/helpers.rb +40 -0
- data/lib/generators/sorcery/install_generator.rb +38 -20
- data/lib/generators/sorcery/templates/initializer.rb +53 -16
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +3 -10
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +3 -7
- data/lib/generators/sorcery/templates/migration/core.rb +5 -8
- data/lib/generators/sorcery/templates/migration/external.rb +3 -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/adapters/active_record_adapter.rb +120 -0
- data/lib/sorcery/adapters/base_adapter.rb +30 -0
- data/lib/sorcery/adapters/data_mapper_adapter.rb +176 -0
- data/lib/sorcery/adapters/mongo_mapper_adapter.rb +110 -0
- data/lib/sorcery/adapters/mongoid_adapter.rb +97 -0
- data/lib/sorcery/controller/config.rb +65 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +27 -21
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +6 -6
- data/lib/sorcery/controller/submodules/external.rb +107 -75
- data/lib/sorcery/controller/submodules/remember_me.rb +5 -5
- data/lib/sorcery/controller/submodules/session_timeout.rb +11 -7
- data/lib/sorcery/controller.rb +27 -76
- data/lib/sorcery/model/config.rb +96 -0
- data/lib/sorcery/model/submodules/activity_logging.rb +32 -12
- data/lib/sorcery/model/submodules/brute_force_protection.rb +36 -36
- data/lib/sorcery/model/submodules/external.rb +53 -9
- data/lib/sorcery/model/submodules/remember_me.rb +15 -19
- data/lib/sorcery/model/submodules/reset_password.rb +36 -33
- data/lib/sorcery/model/submodules/user_activation.rb +51 -48
- data/lib/sorcery/model/temporary_token.rb +4 -4
- data/lib/sorcery/model.rb +85 -175
- data/lib/sorcery/protocols/oauth.rb +42 -0
- data/lib/sorcery/protocols/oauth2.rb +47 -0
- data/lib/sorcery/providers/base.rb +38 -0
- data/lib/sorcery/providers/facebook.rb +74 -0
- data/lib/sorcery/providers/github.rb +60 -0
- data/lib/sorcery/providers/google.rb +51 -0
- data/lib/sorcery/providers/heroku.rb +57 -0
- data/lib/sorcery/providers/jira.rb +77 -0
- data/lib/sorcery/providers/linkedin.rb +66 -0
- data/lib/sorcery/providers/liveid.rb +53 -0
- data/lib/sorcery/providers/salesforce.rb +50 -0
- data/lib/sorcery/providers/twitter.rb +59 -0
- data/lib/sorcery/providers/vk.rb +63 -0
- data/lib/sorcery/providers/xing.rb +64 -0
- data/lib/sorcery/railties/tasks.rake +1 -7
- data/lib/sorcery/test_helpers/internal/rails.rb +17 -6
- data/lib/sorcery/test_helpers/internal.rb +27 -6
- data/lib/sorcery/test_helpers/rails/controller.rb +21 -0
- data/lib/sorcery/test_helpers/rails/integration.rb +26 -0
- data/lib/sorcery/version.rb +3 -0
- data/lib/sorcery.rb +83 -57
- data/sorcery.gemspec +24 -363
- data/spec/active_record/user_activation_spec.rb +18 -0
- data/spec/active_record/user_activity_logging_spec.rb +17 -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/controllers/controller_activity_logging_spec.rb +124 -0
- data/spec/controllers/controller_brute_force_protection_spec.rb +43 -0
- data/spec/controllers/controller_http_basic_auth_spec.rb +68 -0
- data/spec/controllers/controller_oauth2_spec.rb +429 -0
- data/spec/controllers/controller_oauth_spec.rb +240 -0
- data/spec/controllers/controller_remember_me_spec.rb +117 -0
- data/spec/controllers/controller_session_timeout_spec.rb +80 -0
- data/spec/controllers/controller_spec.rb +218 -0
- data/spec/data_mapper/user_activation_spec.rb +10 -0
- data/spec/data_mapper/user_activity_logging_spec.rb +14 -0
- data/spec/data_mapper/user_brute_force_protection_spec.rb +9 -0
- data/spec/data_mapper/user_oauth_spec.rb +9 -0
- data/spec/data_mapper/user_remember_me_spec.rb +8 -0
- data/spec/data_mapper/user_reset_password_spec.rb +8 -0
- data/spec/data_mapper/user_spec.rb +27 -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/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 +51 -0
- data/spec/orm/active_record.rb +21 -0
- data/spec/orm/data_mapper.rb +48 -0
- data/spec/orm/mongo_mapper.rb +10 -0
- data/spec/orm/mongoid.rb +22 -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 +285 -0
- data/spec/rails_app/app/data_mapper/authentication.rb +8 -0
- data/spec/rails_app/app/data_mapper/user.rb +7 -0
- data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/user.rb +2 -0
- data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/user.rb +2 -0
- data/spec/rails_app/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -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 +51 -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/{rails3 → rails_app}/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +2 -0
- data/spec/{rails3 → rails_app}/db/migrate/core/20101224223620_create_users.rb +2 -2
- 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/user_activation_shared_examples.rb +137 -98
- data/spec/shared_examples/user_activity_logging_shared_examples.rb +86 -13
- data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +140 -21
- data/spec/shared_examples/user_oauth_shared_examples.rb +21 -16
- data/spec/shared_examples/user_remember_me_shared_examples.rb +36 -24
- data/spec/shared_examples/user_reset_password_shared_examples.rb +163 -130
- data/spec/shared_examples/user_shared_examples.rb +370 -195
- data/spec/sorcery_crypto_providers_spec.rb +74 -72
- data/spec/spec_helper.rb +32 -4
- metadata +259 -425
- data/Gemfile.lock +0 -192
- data/README.rdoc +0 -261
- data/VERSION +0 -1
- data/lib/sorcery/controller/submodules/external/protocols/oauth1.rb +0 -35
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +0 -45
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +0 -97
- data/lib/sorcery/controller/submodules/external/providers/github.rb +0 -91
- data/lib/sorcery/controller/submodules/external/providers/google.rb +0 -90
- data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +0 -101
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +0 -91
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +0 -92
- data/lib/sorcery/controller/submodules/external/providers/vk.rb +0 -99
- data/lib/sorcery/model/adapters/active_record.rb +0 -49
- data/lib/sorcery/model/adapters/mongo_mapper.rb +0 -56
- data/lib/sorcery/model/adapters/mongoid.rb +0 -88
- data/lib/sorcery/test_helpers/rails.rb +0 -16
- 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/app/views/sorcery_mailer/send_unlock_token_email.text.erb +0 -1
- 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/lib/tasks/.gitkeep +0 -0
- data/spec/rails3/public/404.html +0 -26
- data/spec/rails3/public/422.html +0 -26
- data/spec/rails3/public/500.html +0 -26
- data/spec/rails3/public/favicon.ico +0 -0
- data/spec/rails3/public/images/rails.png +0 -0
- data/spec/rails3/public/javascripts/application.js +0 -2
- data/spec/rails3/public/javascripts/controls.js +0 -965
- data/spec/rails3/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3/public/javascripts/effects.js +0 -1123
- data/spec/rails3/public/javascripts/prototype.js +0 -6001
- data/spec/rails3/public/javascripts/rails.js +0 -175
- data/spec/rails3/public/robots.txt +0 -5
- 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 -115
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +0 -88
- 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_oauth_spec.rb +0 -206
- 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 -177
- data/spec/rails3/spec/integration_spec.rb +0 -23
- 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 -170
- 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 -105
- data/spec/rails3_mongoid/spec/controller_spec.rb +0 -181
- 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/spec/shared_examples/controller_oauth2_shared_examples.rb +0 -56
- data/spec/shared_examples/controller_oauth_shared_examples.rb +0 -55
- /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_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}/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/brute_force_protection/20101224223626_add_brute_force_protection_to_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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Sorcery
|
|
2
2
|
module Model
|
|
3
3
|
module Submodules
|
|
4
|
-
# The Remember Me submodule takes care of setting the user's cookie so that he will
|
|
4
|
+
# The Remember Me submodule takes care of setting the user's cookie so that he will
|
|
5
5
|
# be automatically logged in to the site on every visit,
|
|
6
6
|
# until the cookie expires.
|
|
7
7
|
module RememberMe
|
|
@@ -12,7 +12,7 @@ module Sorcery
|
|
|
12
12
|
:remember_me_for # how long in seconds to remember.
|
|
13
13
|
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
base.sorcery_config.instance_eval do
|
|
17
17
|
@defaults.merge!(:@remember_me_token_attribute_name => :remember_me_token,
|
|
18
18
|
:@remember_me_token_expires_at_attribute_name => :remember_me_token_expires_at,
|
|
@@ -20,47 +20,43 @@ module Sorcery
|
|
|
20
20
|
|
|
21
21
|
reset!
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
base.send(:include, InstanceMethods)
|
|
25
|
+
base.sorcery_config.after_config << :define_remember_me_fields
|
|
25
26
|
|
|
26
|
-
base.sorcery_config.after_config << :define_remember_me_mongoid_fields if defined?(Mongoid) and base.ancestors.include?(Mongoid::Document)
|
|
27
|
-
if defined?(MongoMapper) and base.ancestors.include?(MongoMapper::Document)
|
|
28
|
-
base.sorcery_config.after_config << :define_remember_me_mongo_mapper_fields
|
|
29
|
-
end
|
|
30
|
-
|
|
31
27
|
base.extend(ClassMethods)
|
|
32
28
|
end
|
|
33
29
|
|
|
34
30
|
module ClassMethods
|
|
35
31
|
protected
|
|
36
32
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
def define_remember_me_fields
|
|
34
|
+
sorcery_adapter.define_field sorcery_config.remember_me_token_attribute_name, String
|
|
35
|
+
sorcery_adapter.define_field sorcery_config.remember_me_token_expires_at_attribute_name, Time
|
|
40
36
|
end
|
|
41
37
|
|
|
42
|
-
def define_remember_me_mongo_mapper_fields
|
|
43
|
-
key sorcery_config.remember_me_token_attribute_name, String
|
|
44
|
-
key sorcery_config.remember_me_token_expires_at_attribute_name, Time
|
|
45
|
-
end
|
|
46
38
|
end
|
|
47
39
|
|
|
48
40
|
module InstanceMethods
|
|
49
41
|
# You shouldn't really use this one yourself - it's called by the controller's 'remember_me!' method.
|
|
50
42
|
def remember_me!
|
|
51
43
|
config = sorcery_config
|
|
52
|
-
self.
|
|
44
|
+
self.sorcery_adapter.update_attributes(config.remember_me_token_attribute_name => TemporaryToken.generate_random_token,
|
|
53
45
|
config.remember_me_token_expires_at_attribute_name => Time.now.in_time_zone + config.remember_me_for)
|
|
54
46
|
end
|
|
55
|
-
|
|
47
|
+
|
|
48
|
+
def has_remember_me_token?
|
|
49
|
+
self.send(sorcery_config.remember_me_token_attribute_name).present?
|
|
50
|
+
end
|
|
51
|
+
|
|
56
52
|
# You shouldn't really use this one yourself - it's called by the controller's 'forget_me!' method.
|
|
57
53
|
def forget_me!
|
|
58
54
|
config = sorcery_config
|
|
59
|
-
self.
|
|
55
|
+
self.sorcery_adapter.update_attributes(config.remember_me_token_attribute_name => nil,
|
|
60
56
|
config.remember_me_token_expires_at_attribute_name => nil)
|
|
61
57
|
end
|
|
62
58
|
end
|
|
63
59
|
end
|
|
64
60
|
end
|
|
65
61
|
end
|
|
66
|
-
end
|
|
62
|
+
end
|
|
@@ -9,14 +9,14 @@ module Sorcery
|
|
|
9
9
|
# he will be able to reset his password via a form.
|
|
10
10
|
#
|
|
11
11
|
# When using this submodule, supplying a mailer is mandatory.
|
|
12
|
-
module ResetPassword
|
|
12
|
+
module ResetPassword
|
|
13
13
|
def self.included(base)
|
|
14
14
|
base.sorcery_config.class_eval do
|
|
15
15
|
attr_accessor :reset_password_token_attribute_name, # reset password code attribute name.
|
|
16
16
|
:reset_password_token_expires_at_attribute_name, # expires at attribute name.
|
|
17
17
|
:reset_password_email_sent_at_attribute_name, # when was email sent, used for hammering
|
|
18
18
|
# protection.
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
:reset_password_mailer, # mailer class. Needed.
|
|
21
21
|
|
|
22
22
|
:reset_password_mailer_disabled, # when true sorcery will not automatically
|
|
@@ -25,15 +25,15 @@ module Sorcery
|
|
|
25
25
|
|
|
26
26
|
:reset_password_email_method_name, # reset password email method on your
|
|
27
27
|
# mailer class.
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
:reset_password_expiration_period, # how many seconds before the reset request
|
|
30
30
|
# expires. nil for never expires.
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
:reset_password_time_between_emails # hammering protection, how long to wait
|
|
33
33
|
# before allowing another email to be sent.
|
|
34
34
|
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
base.sorcery_config.instance_eval do
|
|
38
38
|
@defaults.merge!(:@reset_password_token_attribute_name => :reset_password_token,
|
|
39
39
|
:@reset_password_token_expires_at_attribute_name => :reset_password_token_expires_at,
|
|
@@ -50,15 +50,12 @@ module Sorcery
|
|
|
50
50
|
base.extend(ClassMethods)
|
|
51
51
|
|
|
52
52
|
base.sorcery_config.after_config << :validate_mailer_defined
|
|
53
|
-
base.sorcery_config.after_config << :
|
|
54
|
-
if defined?(MongoMapper) and base.ancestors.include?(MongoMapper::Document)
|
|
55
|
-
base.sorcery_config.after_config << :define_reset_password_mongo_mapper_fields
|
|
56
|
-
end
|
|
53
|
+
base.sorcery_config.after_config << :define_reset_password_fields
|
|
57
54
|
|
|
58
55
|
base.send(:include, InstanceMethods)
|
|
59
56
|
|
|
60
57
|
end
|
|
61
|
-
|
|
58
|
+
|
|
62
59
|
module ClassMethods
|
|
63
60
|
# Find user by token, also checks for expiration.
|
|
64
61
|
# Returns the user if token found and is valid.
|
|
@@ -67,9 +64,9 @@ module Sorcery
|
|
|
67
64
|
token_expiration_date_attr = @sorcery_config.reset_password_token_expires_at_attribute_name
|
|
68
65
|
load_from_token(token, token_attr_name, token_expiration_date_attr)
|
|
69
66
|
end
|
|
70
|
-
|
|
67
|
+
|
|
71
68
|
protected
|
|
72
|
-
|
|
69
|
+
|
|
73
70
|
# This submodule requires the developer to define his own mailer class to be used by it
|
|
74
71
|
# when reset_password_mailer_disabled is false
|
|
75
72
|
def validate_mailer_defined
|
|
@@ -77,43 +74,49 @@ module Sorcery
|
|
|
77
74
|
raise ArgumentError, msg if @sorcery_config.reset_password_mailer == nil and @sorcery_config.reset_password_mailer_disabled == false
|
|
78
75
|
end
|
|
79
76
|
|
|
80
|
-
def
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def define_reset_password_mongo_mapper_fields
|
|
87
|
-
key sorcery_config.reset_password_token_attribute_name, String
|
|
88
|
-
key sorcery_config.reset_password_token_expires_at_attribute_name, Time
|
|
89
|
-
key sorcery_config.reset_password_email_sent_at_attribute_name, Time
|
|
77
|
+
def define_reset_password_fields
|
|
78
|
+
sorcery_adapter.define_field sorcery_config.reset_password_token_attribute_name, String
|
|
79
|
+
sorcery_adapter.define_field sorcery_config.reset_password_token_expires_at_attribute_name, Time
|
|
80
|
+
sorcery_adapter.define_field sorcery_config.reset_password_email_sent_at_attribute_name, Time
|
|
90
81
|
end
|
|
82
|
+
|
|
91
83
|
end
|
|
92
|
-
|
|
84
|
+
|
|
93
85
|
module InstanceMethods
|
|
94
|
-
# generates a reset code with expiration
|
|
95
|
-
def
|
|
86
|
+
# generates a reset code with expiration
|
|
87
|
+
def generate_reset_password_token!
|
|
96
88
|
config = sorcery_config
|
|
97
|
-
# hammering protection
|
|
98
|
-
return false if config.reset_password_time_between_emails && self.send(config.reset_password_email_sent_at_attribute_name) && self.send(config.reset_password_email_sent_at_attribute_name) > config.reset_password_time_between_emails.ago.utc
|
|
99
89
|
attributes = {config.reset_password_token_attribute_name => TemporaryToken.generate_random_token,
|
|
100
90
|
config.reset_password_email_sent_at_attribute_name => Time.now.in_time_zone}
|
|
101
91
|
attributes[config.reset_password_token_expires_at_attribute_name] = Time.now.in_time_zone + config.reset_password_expiration_period if config.reset_password_expiration_period
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
|
|
93
|
+
self.sorcery_adapter.update_attributes(attributes)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# generates a reset code with expiration and sends an email to the user.
|
|
97
|
+
def deliver_reset_password_instructions!
|
|
98
|
+
config = sorcery_config
|
|
99
|
+
# hammering protection
|
|
100
|
+
return false if config.reset_password_time_between_emails.present? && self.send(config.reset_password_email_sent_at_attribute_name) && self.send(config.reset_password_email_sent_at_attribute_name) > config.reset_password_time_between_emails.seconds.ago.utc
|
|
101
|
+
self.class.sorcery_adapter.transaction do
|
|
102
|
+
generate_reset_password_token!
|
|
103
|
+
send_reset_password_email! unless config.reset_password_mailer_disabled
|
|
105
104
|
end
|
|
106
105
|
end
|
|
107
|
-
|
|
106
|
+
|
|
108
107
|
# Clears token and tries to update the new password for the user.
|
|
109
108
|
def change_password!(new_password)
|
|
110
109
|
clear_reset_password_token
|
|
111
110
|
self.send(:"#{sorcery_config.password_attribute_name}=", new_password)
|
|
112
|
-
save
|
|
111
|
+
sorcery_adapter.save
|
|
113
112
|
end
|
|
114
113
|
|
|
115
114
|
protected
|
|
116
115
|
|
|
116
|
+
def send_reset_password_email!
|
|
117
|
+
generic_send_email(:reset_password_email_method_name, :reset_password_mailer)
|
|
118
|
+
end
|
|
119
|
+
|
|
117
120
|
# Clears the token.
|
|
118
121
|
def clear_reset_password_token
|
|
119
122
|
config = sorcery_config
|
|
@@ -121,7 +124,7 @@ module Sorcery
|
|
|
121
124
|
self.send(:"#{config.reset_password_token_expires_at_attribute_name}=", nil) if config.reset_password_expiration_period
|
|
122
125
|
end
|
|
123
126
|
end
|
|
124
|
-
|
|
127
|
+
|
|
125
128
|
end
|
|
126
129
|
end
|
|
127
130
|
end
|
|
@@ -10,16 +10,16 @@ module Sorcery
|
|
|
10
10
|
base.sorcery_config.class_eval do
|
|
11
11
|
attr_accessor :activation_state_attribute_name, # the attribute name to hold activation state
|
|
12
12
|
# (active/pending).
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
:activation_token_attribute_name, # the attribute name to hold activation code
|
|
15
15
|
# (sent by email).
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
:activation_token_expires_at_attribute_name, # the attribute name to hold activation code
|
|
18
|
-
# expiration date.
|
|
19
|
-
|
|
18
|
+
# expiration date.
|
|
19
|
+
|
|
20
20
|
:activation_token_expiration_period, # how many seconds before the activation code
|
|
21
21
|
# expires. nil for never expires.
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
:user_activation_mailer, # your mailer class. Required when
|
|
24
24
|
# activation_mailer_disabled == false.
|
|
25
25
|
|
|
@@ -29,14 +29,14 @@ module Sorcery
|
|
|
29
29
|
|
|
30
30
|
:activation_needed_email_method_name, # activation needed email method on your
|
|
31
31
|
# mailer class.
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
:activation_success_email_method_name, # activation success email method on your
|
|
34
34
|
# mailer class.
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
:prevent_non_active_users_to_login # do you want to prevent or allow users that
|
|
37
37
|
# did not activate by email to login?
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
base.sorcery_config.instance_eval do
|
|
41
41
|
@defaults.merge!(:@activation_state_attribute_name => :activation_state,
|
|
42
42
|
:@activation_token_attribute_name => :activation_token,
|
|
@@ -49,27 +49,24 @@ module Sorcery
|
|
|
49
49
|
:@prevent_non_active_users_to_login => true)
|
|
50
50
|
reset!
|
|
51
51
|
end
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
base.class_eval do
|
|
54
54
|
# don't setup activation if no password supplied - this user is created automatically
|
|
55
|
-
|
|
55
|
+
sorcery_adapter.define_callback :before, :create, :setup_activation, :if => Proc.new { |user| user.send(sorcery_config.password_attribute_name).present? }
|
|
56
56
|
# don't send activation needed email if no crypted password created - this user is external (OAuth etc.)
|
|
57
|
-
|
|
57
|
+
sorcery_adapter.define_callback :after, :create, :send_activation_needed_email!, :if => :send_activation_needed_email?
|
|
58
58
|
end
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
base.sorcery_config.after_config << :validate_mailer_defined
|
|
61
|
-
base.sorcery_config.after_config << :
|
|
62
|
-
if defined?(MongoMapper) and base.ancestors.include?(MongoMapper::Document)
|
|
63
|
-
base.sorcery_config.after_config << :define_user_activation_mongo_mapper_fields
|
|
64
|
-
end
|
|
61
|
+
base.sorcery_config.after_config << :define_user_activation_fields
|
|
65
62
|
base.sorcery_config.before_authenticate << :prevent_non_active_login
|
|
66
|
-
|
|
63
|
+
|
|
67
64
|
base.extend(ClassMethods)
|
|
68
65
|
base.send(:include, InstanceMethods)
|
|
69
66
|
|
|
70
67
|
|
|
71
68
|
end
|
|
72
|
-
|
|
69
|
+
|
|
73
70
|
module ClassMethods
|
|
74
71
|
# Find user by token, also checks for expiration.
|
|
75
72
|
# Returns the user if token found and is valid.
|
|
@@ -78,9 +75,9 @@ module Sorcery
|
|
|
78
75
|
token_expiration_date_attr = @sorcery_config.activation_token_expires_at_attribute_name
|
|
79
76
|
load_from_token(token, token_attr_name, token_expiration_date_attr)
|
|
80
77
|
end
|
|
81
|
-
|
|
78
|
+
|
|
82
79
|
protected
|
|
83
|
-
|
|
80
|
+
|
|
84
81
|
# This submodule requires the developer to define his own mailer class to be used by it
|
|
85
82
|
# when activation_mailer_disabled is false
|
|
86
83
|
def validate_mailer_defined
|
|
@@ -88,35 +85,16 @@ module Sorcery
|
|
|
88
85
|
raise ArgumentError, msg if @sorcery_config.user_activation_mailer == nil and @sorcery_config.activation_mailer_disabled == false
|
|
89
86
|
end
|
|
90
87
|
|
|
91
|
-
def
|
|
92
|
-
self.class_eval do
|
|
93
|
-
field sorcery_config.activation_state_attribute_name, :type => String
|
|
94
|
-
field sorcery_config.activation_token_attribute_name, :type => String
|
|
95
|
-
field sorcery_config.activation_token_expires_at_attribute_name, :type => Time
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def define_user_activation_mongo_mapper_fields
|
|
88
|
+
def define_user_activation_fields
|
|
100
89
|
self.class_eval do
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
sorcery_adapter.define_field sorcery_config.activation_state_attribute_name, String
|
|
91
|
+
sorcery_adapter.define_field sorcery_config.activation_token_attribute_name, String
|
|
92
|
+
sorcery_adapter.define_field sorcery_config.activation_token_expires_at_attribute_name, Time
|
|
104
93
|
end
|
|
105
94
|
end
|
|
106
95
|
end
|
|
107
|
-
|
|
108
|
-
module InstanceMethods
|
|
109
|
-
# clears activation code, sets the user as 'active' and optionaly sends a success email.
|
|
110
|
-
def activate!
|
|
111
|
-
config = sorcery_config
|
|
112
|
-
self.send(:"#{config.activation_token_attribute_name}=", nil)
|
|
113
|
-
self.send(:"#{config.activation_state_attribute_name}=", "active")
|
|
114
|
-
send_activation_success_email! unless self.external?
|
|
115
|
-
save!(:validate => false) # don't run validations
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
protected
|
|
119
96
|
|
|
97
|
+
module InstanceMethods
|
|
120
98
|
def setup_activation
|
|
121
99
|
config = sorcery_config
|
|
122
100
|
generated_activation_token = TemporaryToken.generate_random_token
|
|
@@ -125,15 +103,40 @@ module Sorcery
|
|
|
125
103
|
self.send(:"#{config.activation_token_expires_at_attribute_name}=", Time.now.in_time_zone + config.activation_token_expiration_period) if config.activation_token_expiration_period
|
|
126
104
|
end
|
|
127
105
|
|
|
106
|
+
# clears activation code, sets the user as 'active' and optionaly sends a success email.
|
|
107
|
+
def activate!
|
|
108
|
+
config = sorcery_config
|
|
109
|
+
self.send(:"#{config.activation_token_attribute_name}=", nil)
|
|
110
|
+
self.send(:"#{config.activation_state_attribute_name}=", "active")
|
|
111
|
+
send_activation_success_email! if send_activation_success_email?
|
|
112
|
+
sorcery_adapter.save(:validate => false, :raise_on_failure => true)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
protected
|
|
116
|
+
|
|
128
117
|
# called automatically after user initial creation.
|
|
129
118
|
def send_activation_needed_email!
|
|
130
|
-
generic_send_email(:activation_needed_email_method_name, :user_activation_mailer)
|
|
119
|
+
generic_send_email(:activation_needed_email_method_name, :user_activation_mailer)
|
|
131
120
|
end
|
|
132
121
|
|
|
133
122
|
def send_activation_success_email!
|
|
134
|
-
generic_send_email(:activation_success_email_method_name, :user_activation_mailer)
|
|
123
|
+
generic_send_email(:activation_success_email_method_name, :user_activation_mailer)
|
|
135
124
|
end
|
|
136
|
-
|
|
125
|
+
|
|
126
|
+
def send_activation_success_email?
|
|
127
|
+
!external? && (
|
|
128
|
+
!(sorcery_config.activation_success_email_method_name.nil? ||
|
|
129
|
+
sorcery_config.activation_mailer_disabled == true)
|
|
130
|
+
)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def send_activation_needed_email?
|
|
134
|
+
!external? && (
|
|
135
|
+
!(sorcery_config.activation_needed_email_method_name.nil? ||
|
|
136
|
+
sorcery_config.activation_mailer_disabled == true)
|
|
137
|
+
)
|
|
138
|
+
end
|
|
139
|
+
|
|
137
140
|
def prevent_non_active_login
|
|
138
141
|
config = sorcery_config
|
|
139
142
|
config.prevent_non_active_users_to_login ? self.send(config.activation_state_attribute_name) == "active" : true
|
|
@@ -143,4 +146,4 @@ module Sorcery
|
|
|
143
146
|
end
|
|
144
147
|
end
|
|
145
148
|
end
|
|
146
|
-
end
|
|
149
|
+
end
|
|
@@ -3,22 +3,22 @@ require 'securerandom'
|
|
|
3
3
|
module Sorcery
|
|
4
4
|
module Model
|
|
5
5
|
# This module encapsulates the logic for temporary token.
|
|
6
|
-
# A temporary token is created to identify a user in scenarios
|
|
6
|
+
# A temporary token is created to identify a user in scenarios
|
|
7
7
|
# such as reseting password and activating the user by email.
|
|
8
8
|
module TemporaryToken
|
|
9
9
|
def self.included(base)
|
|
10
10
|
base.extend(ClassMethods)
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
# Random code, used for salt and temporary tokens.
|
|
14
14
|
def self.generate_random_token
|
|
15
15
|
SecureRandom.base64(15).tr('+/=lIO0', 'pqrsxyz')
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
module ClassMethods
|
|
19
19
|
def load_from_token(token, token_attr_name, token_expiration_date_attr)
|
|
20
20
|
return nil if token.blank?
|
|
21
|
-
user =
|
|
21
|
+
user = sorcery_adapter.find_by_token(token_attr_name,token)
|
|
22
22
|
if !user.blank? && !user.send(token_expiration_date_attr).nil?
|
|
23
23
|
return Time.now.in_time_zone < user.send(token_expiration_date_attr) ? user : nil
|
|
24
24
|
end
|