loyal_devise 2.1.2 → 2.1.3
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/.gitignore +2 -0
- data/.travis.yml +14 -9
- data/.yardopts +9 -0
- data/CHANGELOG.rdoc +60 -5
- data/CONTRIBUTING.md +4 -2
- data/Gemfile +7 -7
- data/Gemfile.lock +107 -101
- data/MIT-LICENSE +1 -1
- data/README.md +110 -48
- data/Rakefile +1 -0
- data/app/controllers/devise/confirmations_controller.rb +2 -4
- data/app/controllers/devise/omniauth_callbacks_controller.rb +0 -1
- data/app/controllers/devise/passwords_controller.rb +16 -5
- data/app/controllers/devise/registrations_controller.rb +13 -7
- data/app/controllers/devise/sessions_controller.rb +6 -6
- data/app/controllers/devise/unlocks_controller.rb +3 -4
- data/app/controllers/devise_controller.rb +12 -33
- data/app/helpers/devise_helper.rb +0 -1
- data/app/mailers/devise/mailer.rb +7 -8
- data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
- data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +5 -1
- data/config/locales/en.yml +48 -48
- data/devise.gemspec +6 -6
- data/devise.png +0 -0
- data/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-3.2.x} +8 -12
- data/gemfiles/Gemfile.rails-3.2.x.lock +156 -0
- data/lib/devise.rb +34 -11
- data/lib/devise/controllers/helpers.rb +33 -7
- data/lib/devise/controllers/rememberable.rb +6 -3
- data/lib/devise/controllers/scoped_views.rb +1 -2
- data/lib/devise/controllers/url_helpers.rb +0 -1
- data/lib/devise/delegator.rb +0 -1
- data/lib/devise/failure_app.rb +8 -2
- data/lib/devise/hooks/activatable.rb +1 -2
- data/lib/devise/hooks/forgetable.rb +0 -1
- data/lib/devise/hooks/lockable.rb +1 -2
- data/lib/devise/hooks/rememberable.rb +1 -2
- data/lib/devise/hooks/timeoutable.rb +0 -1
- data/lib/devise/hooks/trackable.rb +0 -1
- data/lib/devise/mailers/helpers.rb +18 -14
- data/lib/devise/mapping.rb +6 -7
- data/lib/devise/models.rb +0 -1
- data/lib/devise/models/authenticatable.rb +50 -27
- data/lib/devise/models/confirmable.rb +37 -16
- data/lib/devise/models/database_authenticatable.rb +17 -3
- data/lib/devise/models/lockable.rb +1 -2
- data/lib/devise/models/omniauthable.rb +1 -2
- data/lib/devise/models/recoverable.rb +10 -6
- data/lib/devise/models/registerable.rb +0 -1
- data/lib/devise/models/rememberable.rb +1 -2
- data/lib/devise/models/timeoutable.rb +1 -2
- data/lib/devise/models/token_authenticatable.rb +0 -1
- data/lib/devise/models/trackable.rb +0 -1
- data/lib/devise/models/validatable.rb +0 -1
- data/lib/devise/modules.rb +1 -2
- data/lib/devise/omniauth.rb +0 -1
- data/lib/devise/omniauth/config.rb +0 -1
- data/lib/devise/omniauth/url_helpers.rb +0 -1
- data/lib/devise/orm/active_record.rb +1 -2
- data/lib/devise/orm/mongoid.rb +1 -2
- data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -12
- data/lib/devise/parameter_sanitizer.rb +59 -0
- data/lib/devise/rails.rb +0 -1
- data/lib/devise/rails/routes.rb +22 -18
- data/lib/devise/rails/warden_compat.rb +0 -30
- data/lib/devise/strategies/authenticatable.rb +8 -6
- data/lib/devise/strategies/base.rb +1 -2
- data/lib/devise/strategies/database_authenticatable.rb +1 -2
- data/lib/devise/strategies/rememberable.rb +1 -2
- data/lib/devise/strategies/token_authenticatable.rb +38 -4
- data/lib/devise/test_helpers.rb +0 -1
- data/lib/devise/time_inflector.rb +1 -2
- data/lib/devise/version.rb +1 -2
- data/lib/generators/active_record/devise_generator.rb +1 -5
- data/lib/generators/active_record/templates/migration.rb +0 -1
- data/lib/generators/active_record/templates/migration_existing.rb +0 -1
- data/lib/generators/devise/devise_generator.rb +0 -1
- data/lib/generators/devise/install_generator.rb +0 -1
- data/lib/generators/devise/orm_helpers.rb +1 -2
- data/lib/generators/devise/views_generator.rb +8 -3
- data/lib/generators/mongoid/devise_generator.rb +1 -2
- data/lib/generators/templates/README +1 -1
- data/lib/generators/templates/devise.rb +10 -5
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +1 -0
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -1
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +1 -0
- data/loyal_devise.gemspec +27 -0
- data/test/controllers/custom_strategy_test.rb +0 -1
- data/test/controllers/helpers_test.rb +0 -1
- data/test/controllers/internal_helpers_test.rb +13 -4
- data/test/controllers/passwords_controller_test.rb +32 -0
- data/test/controllers/sessions_controller_test.rb +28 -1
- data/test/controllers/url_helpers_test.rb +0 -1
- data/test/delegator_test.rb +0 -1
- data/test/devise_test.rb +12 -2
- data/test/failure_app_test.rb +3 -4
- data/test/generators/active_record_generator_test.rb +1 -4
- data/test/generators/devise_generator_test.rb +0 -1
- data/test/generators/install_generator_test.rb +0 -1
- data/test/generators/mongoid_generator_test.rb +0 -1
- data/test/generators/views_generator_test.rb +16 -2
- data/test/helpers/devise_helper_test.rb +1 -2
- data/test/integration/authenticatable_test.rb +92 -27
- data/test/integration/confirmable_test.rb +7 -7
- data/test/integration/database_authenticatable_test.rb +8 -7
- data/test/integration/http_authenticatable_test.rb +19 -2
- data/test/integration/lockable_test.rb +1 -2
- data/test/integration/omniauthable_test.rb +2 -3
- data/test/integration/recoverable_test.rb +40 -12
- data/test/integration/registerable_test.rb +17 -14
- data/test/integration/rememberable_test.rb +16 -10
- data/test/integration/timeoutable_test.rb +11 -2
- data/test/integration/token_authenticatable_test.rb +45 -2
- data/test/integration/trackable_test.rb +1 -2
- data/test/mailers/confirmation_instructions_test.rb +11 -3
- data/test/mailers/reset_password_instructions_test.rb +11 -3
- data/test/mailers/unlock_instructions_test.rb +11 -2
- data/test/mapping_test.rb +0 -1
- data/test/models/authenticatable_test.rb +6 -1
- data/test/models/confirmable_test.rb +53 -2
- data/test/models/database_authenticatable_test.rb +57 -21
- data/test/models/lockable_test.rb +1 -2
- data/test/models/omniauthable_test.rb +0 -1
- data/test/models/recoverable_test.rb +21 -5
- data/test/models/registerable_test.rb +0 -1
- data/test/models/rememberable_test.rb +4 -4
- data/test/models/serializable_test.rb +8 -8
- data/test/models/timeoutable_test.rb +0 -1
- data/test/models/token_authenticatable_test.rb +0 -1
- data/test/models/trackable_test.rb +0 -1
- data/test/models/validatable_test.rb +16 -6
- data/test/models_test.rb +7 -24
- data/test/omniauth/config_test.rb +1 -2
- data/test/omniauth/url_helpers_test.rb +4 -2
- data/test/orm/active_record.rb +1 -1
- data/test/orm/mongoid.rb +2 -4
- data/test/parameter_sanitizer_test.rb +51 -0
- data/test/rails_app/Rakefile +0 -4
- data/test/rails_app/app/active_record/admin.rb +0 -1
- data/test/rails_app/app/active_record/shim.rb +1 -2
- data/test/rails_app/app/active_record/user.rb +0 -1
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -2
- data/test/rails_app/app/controllers/admins_controller.rb +0 -1
- data/test/rails_app/app/controllers/application_controller.rb +1 -1
- data/test/rails_app/app/controllers/home_controller.rb +0 -1
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -2
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -2
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -2
- data/test/rails_app/app/controllers/users_controller.rb +8 -1
- data/test/rails_app/app/helpers/application_helper.rb +0 -1
- data/test/rails_app/app/mailers/users/mailer.rb +4 -1
- data/test/rails_app/app/mongoid/admin.rb +4 -3
- data/test/rails_app/app/mongoid/shim.rb +3 -5
- data/test/rails_app/app/mongoid/user.rb +2 -3
- data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +4 -0
- data/test/rails_app/bin/rake +4 -0
- data/test/rails_app/config/application.rb +1 -3
- data/test/rails_app/config/boot.rb +3 -4
- data/test/rails_app/config/environment.rb +2 -3
- data/test/rails_app/config/environments/development.rb +23 -8
- data/test/rails_app/config/environments/production.rb +68 -18
- data/test/rails_app/config/environments/test.rb +18 -16
- data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -1
- data/test/rails_app/config/initializers/devise.rb +0 -1
- data/test/rails_app/config/initializers/inflections.rb +0 -1
- data/test/rails_app/config/initializers/secret_token.rb +8 -3
- data/test/rails_app/config/initializers/session_store.rb +1 -0
- data/test/rails_app/config/routes.rb +20 -17
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -1
- data/test/rails_app/db/schema.rb +0 -1
- data/test/rails_app/lib/shared_admin.rb +0 -1
- data/test/rails_app/lib/shared_user.rb +0 -2
- data/test/routes_test.rb +22 -21
- data/test/support/assertions.rb +0 -1
- data/test/support/helpers.rb +1 -2
- data/test/support/integration.rb +0 -1
- data/test/support/webrat/integrations/rails.rb +0 -1
- data/test/test_helper.rb +8 -2
- data/test/test_helpers_test.rb +0 -1
- data/test/test_models.rb +26 -0
- metadata +65 -27
- data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
- data/test/indifferent_hash.rb +0 -34
- data/test/rails_app/script/rails +0 -10
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
1
|
require 'devise/strategies/authenticatable'
|
|
3
2
|
|
|
4
3
|
module Devise
|
|
@@ -7,7 +6,7 @@ module Devise
|
|
|
7
6
|
class DatabaseAuthenticatable < Authenticatable
|
|
8
7
|
def authenticate!
|
|
9
8
|
resource = valid_password? && mapping.to.find_for_database_authentication(authentication_hash)
|
|
10
|
-
return fail(:
|
|
9
|
+
return fail(:not_found_in_database) unless resource
|
|
11
10
|
|
|
12
11
|
if validate(resource){ resource.valid_password?(password) }
|
|
13
12
|
resource.after_database_authentication
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
1
|
require 'devise/strategies/authenticatable'
|
|
3
2
|
|
|
4
3
|
module Devise
|
|
@@ -42,7 +41,7 @@ module Devise
|
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
def remember_key
|
|
45
|
-
"remember_#{scope}_token"
|
|
44
|
+
mapping.to.rememberable_options.fetch(:key, "remember_#{scope}_token")
|
|
46
45
|
end
|
|
47
46
|
|
|
48
47
|
def remember_cookie
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
1
|
require 'devise/strategies/base'
|
|
3
2
|
|
|
4
3
|
module Devise
|
|
@@ -8,13 +7,22 @@ module Devise
|
|
|
8
7
|
#
|
|
9
8
|
# http://myapp.example.com/?user_token=SECRET
|
|
10
9
|
#
|
|
11
|
-
# For
|
|
12
|
-
# a password, you can pass "X" as
|
|
10
|
+
# For headers, you can use basic authentication passing the token as username and
|
|
11
|
+
# blank password. Since some clients may require a password, you can pass "X" as
|
|
12
|
+
# password and it will simply be ignored.
|
|
13
|
+
#
|
|
14
|
+
# You may also pass the token using the Token authentication mechanism provided
|
|
15
|
+
# by Rails: http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
|
|
16
|
+
# The token options are stored in request.env['devise.token_options']
|
|
13
17
|
class TokenAuthenticatable < Authenticatable
|
|
14
18
|
def store?
|
|
15
19
|
super && !mapping.to.skip_session_storage.include?(:token_auth)
|
|
16
20
|
end
|
|
17
21
|
|
|
22
|
+
def valid?
|
|
23
|
+
super || valid_for_token_auth?
|
|
24
|
+
end
|
|
25
|
+
|
|
18
26
|
def authenticate!
|
|
19
27
|
resource = mapping.to.find_for_token_authentication(authentication_hash)
|
|
20
28
|
return fail(:invalid_token) unless resource
|
|
@@ -37,7 +45,33 @@ module Devise
|
|
|
37
45
|
false
|
|
38
46
|
end
|
|
39
47
|
|
|
40
|
-
#
|
|
48
|
+
# Check if the model accepts this strategy as token authenticatable.
|
|
49
|
+
def token_authenticatable?
|
|
50
|
+
mapping.to.http_authenticatable?(:token_options)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Check if this is strategy is valid for token authentication by:
|
|
54
|
+
#
|
|
55
|
+
# * Validating if the model allows http token authentication;
|
|
56
|
+
# * If the http auth token exists;
|
|
57
|
+
# * If all authentication keys are present;
|
|
58
|
+
#
|
|
59
|
+
def valid_for_token_auth?
|
|
60
|
+
token_authenticatable? && auth_token.present? && with_authentication_hash(:token_auth, token_auth_hash)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Extract the auth token from the request
|
|
64
|
+
def auth_token
|
|
65
|
+
@auth_token ||= ActionController::HttpAuthentication::Token.token_and_options(request)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Extract a hash with attributes:values from the auth_token
|
|
69
|
+
def token_auth_hash
|
|
70
|
+
request.env['devise.token_options'] = auth_token.last
|
|
71
|
+
{ authentication_keys.first => auth_token.first }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Try both scoped and non scoped keys
|
|
41
75
|
def params_auth_hash
|
|
42
76
|
if params[scope].kind_of?(Hash) && params[scope].has_key?(authentication_keys.first)
|
|
43
77
|
params[scope]
|
data/lib/devise/test_helpers.rb
CHANGED
data/lib/devise/version.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
1
|
require 'rails/generators/active_record'
|
|
3
2
|
require 'generators/devise/orm_helpers'
|
|
4
3
|
|
|
@@ -23,10 +22,7 @@ module ActiveRecord
|
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
def inject_devise_content
|
|
26
|
-
content = model_contents
|
|
27
|
-
# Setup accessible (or protected) attributes for your model
|
|
28
|
-
attr_accessible :email, :password, :password_confirmation, :remember_me
|
|
29
|
-
CONTENT
|
|
25
|
+
content = model_contents
|
|
30
26
|
|
|
31
27
|
class_path = if namespaced?
|
|
32
28
|
class_name.to_s.split("::")
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
1
|
module Devise
|
|
3
2
|
module Generators
|
|
4
3
|
# Include this module in your generator to generate Devise views.
|
|
@@ -19,7 +18,7 @@ module Devise
|
|
|
19
18
|
public_task :copy_views
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
# TODO: Add this to Rails
|
|
21
|
+
# TODO: Add this to Rails itself
|
|
23
22
|
module ClassMethods
|
|
24
23
|
def hide!
|
|
25
24
|
Rails::Generators.hide_namespace self.namespace
|
|
@@ -37,7 +36,13 @@ module Devise
|
|
|
37
36
|
protected
|
|
38
37
|
|
|
39
38
|
def view_directory(name, _target_path = nil)
|
|
40
|
-
directory name.to_s, _target_path || "#{target_path}/#{name}"
|
|
39
|
+
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
|
|
40
|
+
if scope
|
|
41
|
+
content.gsub "devise/shared/links", "#{scope}/shared/links"
|
|
42
|
+
else
|
|
43
|
+
content
|
|
44
|
+
end
|
|
45
|
+
end
|
|
41
46
|
end
|
|
42
47
|
|
|
43
48
|
def target_path
|
|
@@ -21,7 +21,7 @@ Some setup you must do manually if you haven't yet:
|
|
|
21
21
|
<p class="notice"><%= notice %></p>
|
|
22
22
|
<p class="alert"><%= alert %></p>
|
|
23
23
|
|
|
24
|
-
4. If you are deploying Rails 3.
|
|
24
|
+
4. If you are deploying on Heroku with Rails 3.2 only, you may want to set:
|
|
25
25
|
|
|
26
26
|
config.assets.initialize_on_precompile = false
|
|
27
27
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
1
|
# Use this hook to configure devise mailer, warden hooks and so forth.
|
|
3
2
|
# Many of these configuration options can be set straight in your model.
|
|
4
3
|
Devise.setup do |config|
|
|
@@ -49,10 +48,14 @@ Devise.setup do |config|
|
|
|
49
48
|
# enable it only for database (email + password) authentication.
|
|
50
49
|
# config.params_authenticatable = true
|
|
51
50
|
|
|
52
|
-
# Tell if authentication through HTTP
|
|
51
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
|
53
52
|
# It can be set to an array that will enable http authentication only for the
|
|
54
53
|
# given strategies, for example, `config.http_authenticatable = [:token]` will
|
|
55
|
-
# enable it only for token authentication.
|
|
54
|
+
# enable it only for token authentication. The supported strategies are:
|
|
55
|
+
# :database = Support basic authentication with authentication key + password
|
|
56
|
+
# :token = Support basic authentication with token authentication key
|
|
57
|
+
# :token_options = Support token authentication with options as defined in
|
|
58
|
+
# http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
|
|
56
59
|
# config.http_authenticatable = false
|
|
57
60
|
|
|
58
61
|
# If http headers should be returned for AJAX requests. True by default.
|
|
@@ -126,7 +129,7 @@ Devise.setup do |config|
|
|
|
126
129
|
config.password_length = 8..128
|
|
127
130
|
|
|
128
131
|
# Email regex used to validate email formats. It simply asserts that
|
|
129
|
-
#
|
|
132
|
+
# one (and only one) @ exists in the given string. This is mainly
|
|
130
133
|
# to give user feedback and not to assert the e-mail validity.
|
|
131
134
|
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
|
132
135
|
|
|
@@ -176,7 +179,9 @@ Devise.setup do |config|
|
|
|
176
179
|
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
|
177
180
|
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
|
178
181
|
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
|
179
|
-
# REST_AUTH_SITE_KEY to pepper)
|
|
182
|
+
# REST_AUTH_SITE_KEY to pepper).
|
|
183
|
+
#
|
|
184
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
|
180
185
|
# config.encryptor = :sha512
|
|
181
186
|
|
|
182
187
|
# ==> Configuration for :token_authenticatable
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<%= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
|
|
4
4
|
<%= f.error_notification %>
|
|
5
|
+
<%= f.full_error :confirmation_token %>
|
|
5
6
|
|
|
6
7
|
<div class="form-inputs">
|
|
7
8
|
<%= f.input :email, :required => true, :autofocus => true %>
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
<div class="form-inputs">
|
|
7
7
|
<%= f.input :email, :required => true, :autofocus => true %>
|
|
8
|
+
|
|
9
|
+
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
|
10
|
+
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
|
|
11
|
+
<% end %>
|
|
12
|
+
|
|
8
13
|
<%= f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false %>
|
|
9
14
|
<%= f.input :password_confirmation, :required => false %>
|
|
10
15
|
<%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %>
|
|
@@ -17,6 +22,6 @@
|
|
|
17
22
|
|
|
18
23
|
<h3>Cancel my account</h3>
|
|
19
24
|
|
|
20
|
-
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete
|
|
25
|
+
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>
|
|
21
26
|
|
|
22
27
|
<%= link_to "Back", :back %>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<%= simple_form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
|
|
4
4
|
<%= f.error_notification %>
|
|
5
|
+
<%= f.full_error :unlock_token %>
|
|
5
6
|
|
|
6
7
|
<div class="form-inputs">
|
|
7
8
|
<%= f.input :email, :required => true, :autofocus => true %>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
# require "devise/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "loyal_devise"
|
|
7
|
+
# s.version = Devise::VERSION.dup
|
|
8
|
+
s.version = '2.1.3'
|
|
9
|
+
s.platform = Gem::Platform::RUBY
|
|
10
|
+
s.licenses = ["MIT"]
|
|
11
|
+
s.summary = "Flexible authentication solution for Rails with Warden"
|
|
12
|
+
s.email = "andywang7259@gmail.com"
|
|
13
|
+
s.homepage = "http://github.com/blogsoso/devise"
|
|
14
|
+
s.description = "Flexible authentication solution for Rails with Warden"
|
|
15
|
+
s.authors = ['happy']
|
|
16
|
+
|
|
17
|
+
# s.rubyforge_project = "devise"
|
|
18
|
+
|
|
19
|
+
s.files = `git ls-files`.split("\n")
|
|
20
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
|
21
|
+
s.require_paths = ["lib"]
|
|
22
|
+
|
|
23
|
+
s.add_dependency("warden", "~> 1.2.1")
|
|
24
|
+
s.add_dependency("orm_adapter", "~> 0.1")
|
|
25
|
+
s.add_dependency("bcrypt-ruby", "~> 3.0")
|
|
26
|
+
s.add_dependency("railties", ">= 3.2.6", "< 5")
|
|
27
|
+
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
1
|
require 'test_helper'
|
|
3
2
|
|
|
4
3
|
class MyController < DeviseController
|
|
@@ -35,10 +34,20 @@ class HelpersTest < ActionController::TestCase
|
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
test 'get resource params from request params using resource name as key' do
|
|
38
|
-
user_params = {'
|
|
39
|
-
@controller.stubs(:params).returns(HashWithIndifferentAccess.new({'user' => user_params}))
|
|
37
|
+
user_params = {'email' => 'shirley@templar.com'}
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
params = if Devise.rails4?
|
|
40
|
+
# Stub controller name so strong parameters can filter properly.
|
|
41
|
+
# DeviseController does not allow any parameters by default.
|
|
42
|
+
@controller.stubs(:controller_name).returns(:sessions_controller)
|
|
43
|
+
|
|
44
|
+
ActionController::Parameters.new({'user' => user_params})
|
|
45
|
+
else
|
|
46
|
+
HashWithIndifferentAccess.new({'user' => user_params})
|
|
47
|
+
end
|
|
48
|
+
@controller.stubs(:params).returns(params)
|
|
49
|
+
|
|
50
|
+
assert_equal user_params, @controller.send(:resource_params)
|
|
42
51
|
end
|
|
43
52
|
|
|
44
53
|
test 'resources methods are not controller actions' do
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class PasswordsControllerTest < ActionController::TestCase
|
|
4
|
+
tests Devise::PasswordsController
|
|
5
|
+
include Devise::TestHelpers
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
request.env["devise.mapping"] = Devise.mappings[:user]
|
|
9
|
+
|
|
10
|
+
@user = create_user
|
|
11
|
+
@user.send_reset_password_instructions
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def put_update_with_params
|
|
15
|
+
put :update, "user" => {
|
|
16
|
+
"reset_password_token" => @user.reset_password_token, "password" => "123456", "password_confirmation" => "123456"
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test 'redirect to after_sign_in_path_for if after_resetting_password_path_for is not overridden' do
|
|
21
|
+
put_update_with_params
|
|
22
|
+
assert_redirected_to "http://test.host/"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test 'redirect accordingly if after_resetting_password_path_for is overridden' do
|
|
26
|
+
custom_path = "http://custom.path/"
|
|
27
|
+
Devise::PasswordsController.any_instance.stubs(:after_resetting_password_path_for).with(@user).returns(custom_path)
|
|
28
|
+
|
|
29
|
+
put_update_with_params
|
|
30
|
+
assert_redirected_to custom_path
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
1
|
require 'test_helper'
|
|
3
2
|
|
|
4
3
|
class SessionsControllerTest < ActionController::TestCase
|
|
@@ -14,6 +13,34 @@ class SessionsControllerTest < ActionController::TestCase
|
|
|
14
13
|
end
|
|
15
14
|
end
|
|
16
15
|
|
|
16
|
+
test "#create delete the url stored in the session if the requested format is navigational" do
|
|
17
|
+
request.env["devise.mapping"] = Devise.mappings[:user]
|
|
18
|
+
request.session["user_return_to"] = 'foo.bar'
|
|
19
|
+
|
|
20
|
+
user = create_user
|
|
21
|
+
user.confirm!
|
|
22
|
+
post :create, :user => {
|
|
23
|
+
:email => user.email,
|
|
24
|
+
:password => user.password
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
assert_nil request.session["user_return_to"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test "#create doesn't delete the url stored in the session if the requested format is not navigational" do
|
|
31
|
+
request.env["devise.mapping"] = Devise.mappings[:user]
|
|
32
|
+
request.session["user_return_to"] = 'foo.bar'
|
|
33
|
+
|
|
34
|
+
user = create_user
|
|
35
|
+
user.confirm!
|
|
36
|
+
post :create, :format => 'json', :user => {
|
|
37
|
+
:email => user.email,
|
|
38
|
+
:password => user.password
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
assert_equal 'foo.bar', request.session["user_return_to"]
|
|
42
|
+
end
|
|
43
|
+
|
|
17
44
|
test "#create doesn't raise exception after Warden authentication fails when TestHelpers included" do
|
|
18
45
|
request.env["devise.mapping"] = Devise.mappings[:user]
|
|
19
46
|
post :create, :user => {
|