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.
Files changed (188) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +14 -9
  3. data/.yardopts +9 -0
  4. data/CHANGELOG.rdoc +60 -5
  5. data/CONTRIBUTING.md +4 -2
  6. data/Gemfile +7 -7
  7. data/Gemfile.lock +107 -101
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +110 -48
  10. data/Rakefile +1 -0
  11. data/app/controllers/devise/confirmations_controller.rb +2 -4
  12. data/app/controllers/devise/omniauth_callbacks_controller.rb +0 -1
  13. data/app/controllers/devise/passwords_controller.rb +16 -5
  14. data/app/controllers/devise/registrations_controller.rb +13 -7
  15. data/app/controllers/devise/sessions_controller.rb +6 -6
  16. data/app/controllers/devise/unlocks_controller.rb +3 -4
  17. data/app/controllers/devise_controller.rb +12 -33
  18. data/app/helpers/devise_helper.rb +0 -1
  19. data/app/mailers/devise/mailer.rb +7 -8
  20. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  21. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  22. data/app/views/devise/registrations/edit.html.erb +5 -1
  23. data/config/locales/en.yml +48 -48
  24. data/devise.gemspec +6 -6
  25. data/devise.png +0 -0
  26. data/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-3.2.x} +8 -12
  27. data/gemfiles/Gemfile.rails-3.2.x.lock +156 -0
  28. data/lib/devise.rb +34 -11
  29. data/lib/devise/controllers/helpers.rb +33 -7
  30. data/lib/devise/controllers/rememberable.rb +6 -3
  31. data/lib/devise/controllers/scoped_views.rb +1 -2
  32. data/lib/devise/controllers/url_helpers.rb +0 -1
  33. data/lib/devise/delegator.rb +0 -1
  34. data/lib/devise/failure_app.rb +8 -2
  35. data/lib/devise/hooks/activatable.rb +1 -2
  36. data/lib/devise/hooks/forgetable.rb +0 -1
  37. data/lib/devise/hooks/lockable.rb +1 -2
  38. data/lib/devise/hooks/rememberable.rb +1 -2
  39. data/lib/devise/hooks/timeoutable.rb +0 -1
  40. data/lib/devise/hooks/trackable.rb +0 -1
  41. data/lib/devise/mailers/helpers.rb +18 -14
  42. data/lib/devise/mapping.rb +6 -7
  43. data/lib/devise/models.rb +0 -1
  44. data/lib/devise/models/authenticatable.rb +50 -27
  45. data/lib/devise/models/confirmable.rb +37 -16
  46. data/lib/devise/models/database_authenticatable.rb +17 -3
  47. data/lib/devise/models/lockable.rb +1 -2
  48. data/lib/devise/models/omniauthable.rb +1 -2
  49. data/lib/devise/models/recoverable.rb +10 -6
  50. data/lib/devise/models/registerable.rb +0 -1
  51. data/lib/devise/models/rememberable.rb +1 -2
  52. data/lib/devise/models/timeoutable.rb +1 -2
  53. data/lib/devise/models/token_authenticatable.rb +0 -1
  54. data/lib/devise/models/trackable.rb +0 -1
  55. data/lib/devise/models/validatable.rb +0 -1
  56. data/lib/devise/modules.rb +1 -2
  57. data/lib/devise/omniauth.rb +0 -1
  58. data/lib/devise/omniauth/config.rb +0 -1
  59. data/lib/devise/omniauth/url_helpers.rb +0 -1
  60. data/lib/devise/orm/active_record.rb +1 -2
  61. data/lib/devise/orm/mongoid.rb +1 -2
  62. data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -12
  63. data/lib/devise/parameter_sanitizer.rb +59 -0
  64. data/lib/devise/rails.rb +0 -1
  65. data/lib/devise/rails/routes.rb +22 -18
  66. data/lib/devise/rails/warden_compat.rb +0 -30
  67. data/lib/devise/strategies/authenticatable.rb +8 -6
  68. data/lib/devise/strategies/base.rb +1 -2
  69. data/lib/devise/strategies/database_authenticatable.rb +1 -2
  70. data/lib/devise/strategies/rememberable.rb +1 -2
  71. data/lib/devise/strategies/token_authenticatable.rb +38 -4
  72. data/lib/devise/test_helpers.rb +0 -1
  73. data/lib/devise/time_inflector.rb +1 -2
  74. data/lib/devise/version.rb +1 -2
  75. data/lib/generators/active_record/devise_generator.rb +1 -5
  76. data/lib/generators/active_record/templates/migration.rb +0 -1
  77. data/lib/generators/active_record/templates/migration_existing.rb +0 -1
  78. data/lib/generators/devise/devise_generator.rb +0 -1
  79. data/lib/generators/devise/install_generator.rb +0 -1
  80. data/lib/generators/devise/orm_helpers.rb +1 -2
  81. data/lib/generators/devise/views_generator.rb +8 -3
  82. data/lib/generators/mongoid/devise_generator.rb +1 -2
  83. data/lib/generators/templates/README +1 -1
  84. data/lib/generators/templates/devise.rb +10 -5
  85. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  86. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +1 -0
  87. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -1
  88. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +1 -0
  89. data/loyal_devise.gemspec +27 -0
  90. data/test/controllers/custom_strategy_test.rb +0 -1
  91. data/test/controllers/helpers_test.rb +0 -1
  92. data/test/controllers/internal_helpers_test.rb +13 -4
  93. data/test/controllers/passwords_controller_test.rb +32 -0
  94. data/test/controllers/sessions_controller_test.rb +28 -1
  95. data/test/controllers/url_helpers_test.rb +0 -1
  96. data/test/delegator_test.rb +0 -1
  97. data/test/devise_test.rb +12 -2
  98. data/test/failure_app_test.rb +3 -4
  99. data/test/generators/active_record_generator_test.rb +1 -4
  100. data/test/generators/devise_generator_test.rb +0 -1
  101. data/test/generators/install_generator_test.rb +0 -1
  102. data/test/generators/mongoid_generator_test.rb +0 -1
  103. data/test/generators/views_generator_test.rb +16 -2
  104. data/test/helpers/devise_helper_test.rb +1 -2
  105. data/test/integration/authenticatable_test.rb +92 -27
  106. data/test/integration/confirmable_test.rb +7 -7
  107. data/test/integration/database_authenticatable_test.rb +8 -7
  108. data/test/integration/http_authenticatable_test.rb +19 -2
  109. data/test/integration/lockable_test.rb +1 -2
  110. data/test/integration/omniauthable_test.rb +2 -3
  111. data/test/integration/recoverable_test.rb +40 -12
  112. data/test/integration/registerable_test.rb +17 -14
  113. data/test/integration/rememberable_test.rb +16 -10
  114. data/test/integration/timeoutable_test.rb +11 -2
  115. data/test/integration/token_authenticatable_test.rb +45 -2
  116. data/test/integration/trackable_test.rb +1 -2
  117. data/test/mailers/confirmation_instructions_test.rb +11 -3
  118. data/test/mailers/reset_password_instructions_test.rb +11 -3
  119. data/test/mailers/unlock_instructions_test.rb +11 -2
  120. data/test/mapping_test.rb +0 -1
  121. data/test/models/authenticatable_test.rb +6 -1
  122. data/test/models/confirmable_test.rb +53 -2
  123. data/test/models/database_authenticatable_test.rb +57 -21
  124. data/test/models/lockable_test.rb +1 -2
  125. data/test/models/omniauthable_test.rb +0 -1
  126. data/test/models/recoverable_test.rb +21 -5
  127. data/test/models/registerable_test.rb +0 -1
  128. data/test/models/rememberable_test.rb +4 -4
  129. data/test/models/serializable_test.rb +8 -8
  130. data/test/models/timeoutable_test.rb +0 -1
  131. data/test/models/token_authenticatable_test.rb +0 -1
  132. data/test/models/trackable_test.rb +0 -1
  133. data/test/models/validatable_test.rb +16 -6
  134. data/test/models_test.rb +7 -24
  135. data/test/omniauth/config_test.rb +1 -2
  136. data/test/omniauth/url_helpers_test.rb +4 -2
  137. data/test/orm/active_record.rb +1 -1
  138. data/test/orm/mongoid.rb +2 -4
  139. data/test/parameter_sanitizer_test.rb +51 -0
  140. data/test/rails_app/Rakefile +0 -4
  141. data/test/rails_app/app/active_record/admin.rb +0 -1
  142. data/test/rails_app/app/active_record/shim.rb +1 -2
  143. data/test/rails_app/app/active_record/user.rb +0 -1
  144. data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -2
  145. data/test/rails_app/app/controllers/admins_controller.rb +0 -1
  146. data/test/rails_app/app/controllers/application_controller.rb +1 -1
  147. data/test/rails_app/app/controllers/home_controller.rb +0 -1
  148. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -2
  149. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -2
  150. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -2
  151. data/test/rails_app/app/controllers/users_controller.rb +8 -1
  152. data/test/rails_app/app/helpers/application_helper.rb +0 -1
  153. data/test/rails_app/app/mailers/users/mailer.rb +4 -1
  154. data/test/rails_app/app/mongoid/admin.rb +4 -3
  155. data/test/rails_app/app/mongoid/shim.rb +3 -5
  156. data/test/rails_app/app/mongoid/user.rb +2 -3
  157. data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
  158. data/test/rails_app/bin/bundle +3 -0
  159. data/test/rails_app/bin/rails +4 -0
  160. data/test/rails_app/bin/rake +4 -0
  161. data/test/rails_app/config/application.rb +1 -3
  162. data/test/rails_app/config/boot.rb +3 -4
  163. data/test/rails_app/config/environment.rb +2 -3
  164. data/test/rails_app/config/environments/development.rb +23 -8
  165. data/test/rails_app/config/environments/production.rb +68 -18
  166. data/test/rails_app/config/environments/test.rb +18 -16
  167. data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -1
  168. data/test/rails_app/config/initializers/devise.rb +0 -1
  169. data/test/rails_app/config/initializers/inflections.rb +0 -1
  170. data/test/rails_app/config/initializers/secret_token.rb +8 -3
  171. data/test/rails_app/config/initializers/session_store.rb +1 -0
  172. data/test/rails_app/config/routes.rb +20 -17
  173. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -1
  174. data/test/rails_app/db/schema.rb +0 -1
  175. data/test/rails_app/lib/shared_admin.rb +0 -1
  176. data/test/rails_app/lib/shared_user.rb +0 -2
  177. data/test/routes_test.rb +22 -21
  178. data/test/support/assertions.rb +0 -1
  179. data/test/support/helpers.rb +1 -2
  180. data/test/support/integration.rb +0 -1
  181. data/test/support/webrat/integrations/rails.rb +0 -1
  182. data/test/test_helper.rb +8 -2
  183. data/test/test_helpers_test.rb +0 -1
  184. data/test/test_models.rb +26 -0
  185. metadata +65 -27
  186. data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
  187. data/test/indifferent_hash.rb +0 -34
  188. data/test/rails_app/script/rails +0 -10
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Devise
3
2
  module Strategies
4
3
  # Base strategy for Devise. Responsible for verifying correct scope and mapping.
@@ -18,4 +17,4 @@ module Devise
18
17
  end
19
18
  end
20
19
  end
21
- end
20
+ end
@@ -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(:invalid) unless resource
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 HTTP, you can pass the token as username and blank password. Since some clients may require
12
- # a password, you can pass "X" as password and it will simply be ignored.
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
- # Try both scoped and non scoped keys.
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]
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Devise
3
2
  # Devise::TestHelpers provides a facility to test controllers in isolation
4
3
  # when using ActionController::TestCase allowing you to quickly sign_in or
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require "active_support/core_ext/module/delegation"
3
2
 
4
3
  module Devise
@@ -12,4 +11,4 @@ module Devise
12
11
 
13
12
  @instance = new
14
13
  end
15
- end
14
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Devise
3
- VERSION = "2.1.2".freeze
2
+ VERSION = "3.0.0.rc".freeze
4
3
  end
@@ -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 + <<CONTENT
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
  class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
3
2
  def change
4
3
  create_table(:<%= table_name %>) do |t|
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration
3
2
  def self.up
4
3
  change_table(:<%= table_name %>) do |t|
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Devise
3
2
  module Generators
4
3
  class DeviseGenerator < Rails::Generators::NamedBase
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'securerandom'
3
2
 
4
3
  module Devise
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Devise
3
2
  module Generators
4
3
  module OrmHelpers
@@ -30,4 +29,4 @@ CONTENT
30
29
  end
31
30
  end
32
31
  end
33
- end
32
+ end
@@ -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 itslef
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
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'generators/devise/orm_helpers'
3
2
 
4
3
  module Mongoid
@@ -55,4 +54,4 @@ RUBY
55
54
  end
56
55
  end
57
56
  end
58
- end
57
+ end
@@ -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.1+ on Heroku, you may want to set:
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 Basic Auth is enabled. False by default.
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
- # an one (and only one) @ exists in the given string. This is mainly
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
@@ -1,4 +1,4 @@
1
- Welcome <%= @resource.email %>!
1
+ Welcome <%= @email %>!
2
2
 
3
3
  You can confirm your account through the link below:
4
4
 
@@ -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 %>.</p>
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
  require 'ostruct'
4
3
  require 'warden/strategies/base'
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'test_helper'
3
2
  require 'ostruct'
4
3
 
@@ -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 = {'name' => 'Shirley Templar'}
39
- @controller.stubs(:params).returns(HashWithIndifferentAccess.new({'user' => user_params}))
37
+ user_params = {'email' => 'shirley@templar.com'}
40
38
 
41
- assert_equal user_params, @controller.resource_params
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 => {