devise 3.4.0 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4a63d11db247c5ff37458c4428aeab1157a8348
4
- data.tar.gz: e7f12ffe07a25af2e7c237d730292ac3802ee485
3
+ metadata.gz: d870f50c7470c763a16239c45bfb289c6a2b4515
4
+ data.tar.gz: 0d38550a1563a511dd37b3fd7f7ce0cac3886108
5
5
  SHA512:
6
- metadata.gz: d3ba135a520942fca0de03af35fdf6cb1d898abba04dba3febc20e59b6f879e56d8d59f6009a5086e9bbee2747abd6ae41c33d5e6d36d6b39d2963ebafa3d6df
7
- data.tar.gz: 8c44ba76ff75f1a917901351879c43c72e23cb0f994ce1723d9814f3f022b3be388c474579fc7cd400135b743e5d13ebeaa52b8a5c4da86418d2321a2e1a6090
6
+ metadata.gz: d506c1450e20586c49e8ce2202821c2ed78d266876cb7c075795ea5efacaf748361cfdfc524dc2c87e7e093d2a85a9d8dd86faf12fa1c3b2fba1f691b0ceac29
7
+ data.tar.gz: a486ab066399291c8d4bdfb73c789c44f11d26722d2a9f3f6fd7ffc9e5933a6e3f6383c39ff62a68cbf025c0e0c087a5732a5801377e4758e1a83656d0476479
@@ -1,7 +1,14 @@
1
1
  ### Unreleased
2
2
 
3
+ ### 3.4.1
4
+
3
5
  * enhancements
6
+ * Devise default views now have a similar markup to Rails scaffold views. (by @udaysinghcode, @cllns)
7
+ * Passing `now: true` to the `set_flash_message` helper now sets the message into
8
+ the `flash.now` Hash. (by @hbriggs)
4
9
  * bugfixes
10
+ * Fixed an regression with translation of flash messages for when the `authentication_keys`
11
+ config is a Hash. (by @lucasmazza)
5
12
 
6
13
  ### 3.4.0
7
14
 
@@ -10,7 +17,6 @@
10
17
  the extraction of the `respond_with` API from Rails. (by @lucasmazza)
11
18
  * The Simple Form templates follow the same change from 3.3.0 by using `Log in` and adding
12
19
  a hint about the minimum password length when `validatable` is enabled. (by @aried3r)
13
- * Remove reloading of routes when eager loading is enabled. This change was added during Rails 3 and it doesn't seem to be relevant to currently supported Rails versions (by @fgro)
14
20
  * Controller generator added as `devise:controllers SCOPE`. You can use the `-c` flag
15
21
  to pick which controllers (`unlocks`, `confirmations`, etc) you want to generate. (by @Chun-Yang)
16
22
  * Removed the hardcoded references for "email" in the flash messages. If you are using
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- devise (3.4.0)
15
+ devise (3.4.1)
16
16
  bcrypt (~> 3.0)
17
17
  orm_adapter (~> 0.1)
18
18
  railties (>= 3.2.6, < 5)
data/README.md CHANGED
@@ -289,11 +289,11 @@ If the customization at the views level is not enough, you can customize each co
289
289
  rails generate devise:controllers [scope]
290
290
  ```
291
291
 
292
- If you specify `admins` as the scope, controllers will be created in `app/controllers/admins/`.
292
+ If you specify `users` as the scope, controllers will be created in `app/controllers/users/`.
293
293
  And the sessions controller will look like this:
294
294
 
295
295
  ```ruby
296
- class Admins::SessionsController < Devise::SessionsController
296
+ class Users::SessionsController < Devise::SessionsController
297
297
  # GET /resource/sign_in
298
298
  # def new
299
299
  # super
@@ -305,17 +305,17 @@ If the customization at the views level is not enough, you can customize each co
305
305
  2. Tell the router to use this controller:
306
306
 
307
307
  ```ruby
308
- devise_for :admins, controllers: { sessions: "admins/sessions" }
308
+ devise_for :users, controllers: { sessions: "users/sessions" }
309
309
  ```
310
310
 
311
- 3. Copy the views from `devise/sessions` to `admins/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
311
+ 3. Copy the views from `devise/sessions` to `users/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
312
312
 
313
313
  4. Finally, change or extend the desired controller actions.
314
314
 
315
315
  You can completely override a controller action:
316
316
 
317
317
  ```ruby
318
- class Admins::SessionsController < Devise::SessionsController
318
+ class Users::SessionsController < Devise::SessionsController
319
319
  def create
320
320
  # custom sign-in code
321
321
  end
@@ -325,7 +325,7 @@ If the customization at the views level is not enough, you can customize each co
325
325
  Or you can simply add new behaviour to it:
326
326
 
327
327
  ```ruby
328
- class Admins::SessionsController < Devise::SessionsController
328
+ class Users::SessionsController < Devise::SessionsController
329
329
  def create
330
330
  super do |resource|
331
331
  BackgroundWorker.trigger(resource)
@@ -129,8 +129,11 @@ MESSAGE
129
129
  end
130
130
 
131
131
  # Sets the flash message with :key, using I18n. By default you are able
132
- # to setup your messages using specific resource scope, and if no one is
133
- # found we look to default scope.
132
+ # to setup your messages using specific resource scope, and if no message is
133
+ # found we look to the default scope. Set the "now" options key to a true
134
+ # value to populate the flash.now hash in lieu of the default flash hash (so
135
+ # the flash message will be available to the current action instead of the
136
+ # next action).
134
137
  # Example (i18n locale file):
135
138
  #
136
139
  # en:
@@ -144,7 +147,11 @@ MESSAGE
144
147
  # available.
145
148
  def set_flash_message(key, kind, options = {})
146
149
  message = find_message(kind, options)
147
- flash[key] = message if message.present?
150
+ if options[:now]
151
+ flash.now[key] = message if message.present?
152
+ else
153
+ flash[key] = message if message.present?
154
+ end
148
155
  end
149
156
 
150
157
  def devise_i18n_options(options)
@@ -3,10 +3,14 @@
3
3
  <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email, autofocus: true %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
8
10
 
9
- <div><%= f.submit "Resend confirmation instructions" %></div>
11
+ <div class="actions">
12
+ <%= f.submit "Resend confirmation instructions" %>
13
+ </div>
10
14
  <% end %>
11
15
 
12
16
  <%= render "devise/shared/links" %>
@@ -4,13 +4,19 @@
4
4
  <%= devise_error_messages! %>
5
5
  <%= f.hidden_field :reset_password_token %>
6
6
 
7
- <div><%= f.label :password, "New password" %><br />
8
- <%= f.password_field :password, autofocus: true, autocomplete: "off" %></div>
7
+ <div class="field">
8
+ <%= f.label :password, "New password" %><br />
9
+ <%= f.password_field :password, autofocus: true, autocomplete: "off" %>
10
+ </div>
9
11
 
10
- <div><%= f.label :password_confirmation, "Confirm new password" %><br />
11
- <%= f.password_field :password_confirmation, autocomplete: "off" %></div>
12
+ <div class="field">
13
+ <%= f.label :password_confirmation, "Confirm new password" %><br />
14
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
15
+ </div>
12
16
 
13
- <div><%= f.submit "Change my password" %></div>
17
+ <div class="actions">
18
+ <%= f.submit "Change my password" %>
19
+ </div>
14
20
  <% end %>
15
21
 
16
22
  <%= render "devise/shared/links" %>
@@ -3,10 +3,14 @@
3
3
  <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email, autofocus: true %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
8
10
 
9
- <div><%= f.submit "Send me reset password instructions" %></div>
11
+ <div class="actions">
12
+ <%= f.submit "Send me reset password instructions" %>
13
+ </div>
10
14
  <% end %>
11
15
 
12
16
  <%= render "devise/shared/links" %>
@@ -3,23 +3,33 @@
3
3
  <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email, autofocus: true %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
8
10
 
9
11
  <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
10
12
  <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
11
13
  <% end %>
12
14
 
13
- <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
14
- <%= f.password_field :password, autocomplete: "off" %></div>
15
+ <div class="field">
16
+ <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
17
+ <%= f.password_field :password, autocomplete: "off" %>
18
+ </div>
15
19
 
16
- <div><%= f.label :password_confirmation %><br />
17
- <%= f.password_field :password_confirmation, autocomplete: "off" %></div>
20
+ <div class="field">
21
+ <%= f.label :password_confirmation %><br />
22
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
23
+ </div>
18
24
 
19
- <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
20
- <%= f.password_field :current_password, autocomplete: "off" %></div>
25
+ <div class="field">
26
+ <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
27
+ <%= f.password_field :current_password, autocomplete: "off" %>
28
+ </div>
21
29
 
22
- <div><%= f.submit "Update" %></div>
30
+ <div class="actions">
31
+ <%= f.submit "Update" %>
32
+ </div>
23
33
  <% end %>
24
34
 
25
35
  <h3>Cancel my account</h3>
@@ -3,16 +3,27 @@
3
3
  <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email, autofocus: true %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
8
10
 
9
- <div><%= f.label :password %> <% if @validatable %><i>(<%= @minimum_password_length %> characters minimum)</i><% end %><br />
10
- <%= f.password_field :password, autocomplete: "off" %></div>
11
+ <div class="field">
12
+ <%= f.label :password %>
13
+ <% if @validatable %>
14
+ <em>(<%= @minimum_password_length %> characters minimum)</em>
15
+ <% end %><br />
16
+ <%= f.password_field :password, autocomplete: "off" %>
17
+ </div>
11
18
 
12
- <div><%= f.label :password_confirmation %><br />
13
- <%= f.password_field :password_confirmation, autocomplete: "off" %></div>
19
+ <div class="field">
20
+ <%= f.label :password_confirmation %><br />
21
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
22
+ </div>
14
23
 
15
- <div><%= f.submit "Sign up" %></div>
24
+ <div class="actions">
25
+ <%= f.submit "Sign up" %>
26
+ </div>
16
27
  <% end %>
17
28
 
18
29
  <%= render "devise/shared/links" %>
@@ -1,17 +1,26 @@
1
1
  <h2>Log in</h2>
2
2
 
3
3
  <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
- <div><%= f.label :email %><br />
5
- <%= f.email_field :email, autofocus: true %></div>
4
+ <div class="field">
5
+ <%= f.label :email %><br />
6
+ <%= f.email_field :email, autofocus: true %>
7
+ </div>
6
8
 
7
- <div><%= f.label :password %><br />
8
- <%= f.password_field :password, autocomplete: "off" %></div>
9
+ <div class="field">
10
+ <%= f.label :password %><br />
11
+ <%= f.password_field :password, autocomplete: "off" %>
12
+ </div>
9
13
 
10
14
  <% if devise_mapping.rememberable? -%>
11
- <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
15
+ <div class="field">
16
+ <%= f.check_box :remember_me %>
17
+ <%= f.label :remember_me %>
18
+ </div>
12
19
  <% end -%>
13
20
 
14
- <div><%= f.submit "Log in" %></div>
21
+ <div class="actions">
22
+ <%= f.submit "Log in" %>
23
+ </div>
15
24
  <% end %>
16
25
 
17
26
  <%= render "devise/shared/links" %>
@@ -3,10 +3,14 @@
3
3
  <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
- <div><%= f.label :email %><br />
7
- <%= f.email_field :email, autofocus: true %></div>
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
8
10
 
9
- <div><%= f.submit "Resend unlock instructions" %></div>
11
+ <div class="actions">
12
+ <%= f.submit "Resend unlock instructions" %>
13
+ </div>
10
14
  <% end %>
11
15
 
12
16
  <%= render "devise/shared/links" %>
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.files = `git ls-files`.split("\n")
19
19
  s.test_files = `git ls-files -- test/*`.split("\n")
20
20
  s.require_paths = ["lib"]
21
+ s.required_ruby_version = '>= 1.9.3'
21
22
 
22
23
  s.add_dependency("warden", "~> 1.2.3")
23
24
  s.add_dependency("orm_adapter", "~> 0.1")
@@ -49,7 +49,7 @@ GIT
49
49
  PATH
50
50
  remote: ..
51
51
  specs:
52
- devise (3.4.0)
52
+ devise (3.4.1)
53
53
  bcrypt (~> 3.0)
54
54
  orm_adapter (~> 0.1)
55
55
  railties (>= 3.2.6, < 5)
@@ -43,7 +43,7 @@ GIT
43
43
  PATH
44
44
  remote: ..
45
45
  specs:
46
- devise (3.4.0)
46
+ devise (3.4.1)
47
47
  bcrypt (~> 3.0)
48
48
  orm_adapter (~> 0.1)
49
49
  railties (>= 3.2.6, < 5)
@@ -48,7 +48,7 @@ GIT
48
48
  PATH
49
49
  remote: ..
50
50
  specs:
51
- devise (3.4.0)
51
+ devise (3.4.1)
52
52
  bcrypt (~> 3.0)
53
53
  orm_adapter (~> 0.1)
54
54
  railties (>= 3.2.6, < 5)
@@ -78,7 +78,9 @@ module Devise
78
78
  options[:resource_name] = scope
79
79
  options[:scope] = "devise.failure"
80
80
  options[:default] = [message]
81
- options[:authentication_keys] = scope_class.authentication_keys.join(I18n.translate(:"support.array.words_connector"))
81
+ auth_keys = scope_class.authentication_keys
82
+ keys = auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys
83
+ options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
82
84
  options = i18n_options(options)
83
85
 
84
86
  I18n.t(:"#{scope}.#{message}", options)
@@ -1,3 +1,3 @@
1
1
  module Devise
2
- VERSION = "3.4.0".freeze
2
+ VERSION = "3.4.1".freeze
3
3
  end
@@ -8,7 +8,7 @@ module Devise
8
8
  desc <<-DESC.strip_heredoc
9
9
  Create inherited Devise controllers in your app/controllers folder.
10
10
 
11
- User -c to specify which controller you want to overwrite.
11
+ Use -c to specify which controller you want to overwrite.
12
12
  If you do no specify a controller, all controllers will be created.
13
13
  For example:
14
14
 
@@ -99,6 +99,12 @@ class HelpersTest < ActionController::TestCase
99
99
  assert_equal 'non-blank', flash[:notice]
100
100
  end
101
101
 
102
+ test 'issues non-blank flash.now messages normally' do
103
+ I18n.stubs(:t).returns('non-blank')
104
+ @controller.send :set_flash_message, :notice, :send_instructions, { now: true }
105
+ assert_equal 'non-blank', flash.now[:notice]
106
+ end
107
+
102
108
  test 'uses custom i18n options' do
103
109
  @controller.stubs(:devise_i18n_options).returns(default: "devise custom options")
104
110
  @controller.send :set_flash_message, :notice, :invalid_i18n_messagesend_instructions
@@ -109,6 +109,13 @@ class FailureTest < ActiveSupport::TestCase
109
109
  assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
110
110
  end
111
111
 
112
+ test 'supports authentication_keys as a Hash for the flash message' do
113
+ swap Devise, authentication_keys: { email: true, login: true } do
114
+ call_failure('warden' => OpenStruct.new(message: :invalid))
115
+ assert_equal 'Invalid email, login or password.', @request.flash[:alert]
116
+ end
117
+ end
118
+
112
119
  test 'uses custom i18n options' do
113
120
  call_failure('warden' => OpenStruct.new(message: :does_not_exist), app: FailureWithI18nOptions)
114
121
  assert_equal 'User Steve does not exist', @request.flash[:alert]
@@ -219,14 +219,14 @@ class ConfirmableTest < ActiveSupport::TestCase
219
219
  test 'should not be active when confirm in is zero' do
220
220
  Devise.allow_unconfirmed_access_for = 0.days
221
221
  user = create_user
222
- user.confirmation_sent_at = Date.today
222
+ user.confirmation_sent_at = Time.zone.today
223
223
  assert_not user.active_for_authentication?
224
224
  end
225
225
 
226
226
  test 'should be active when we set allow_unconfirmed_access_for to nil' do
227
227
  swap Devise, allow_unconfirmed_access_for: nil do
228
228
  user = create_user
229
- user.confirmation_sent_at = Date.today
229
+ user.confirmation_sent_at = Time.zone.today
230
230
  assert user.active_for_authentication?
231
231
  end
232
232
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Valim
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-03 00:00:00.000000000 Z
12
+ date: 2014-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: warden
@@ -362,7 +362,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
362
362
  requirements:
363
363
  - - ">="
364
364
  - !ruby/object:Gem::Version
365
- version: '0'
365
+ version: 1.9.3
366
366
  required_rubygems_version: !ruby/object:Gem::Requirement
367
367
  requirements:
368
368
  - - ">="