Upgrade Devise to 3.4.0.

Rebase view files onto the latest template files.

Akinori MUSHA 10 gadi atpakaļ
vecāks
revīzija
cd2b335cc5

+ 1 - 1
Gemfile

@@ -46,7 +46,7 @@ gem 'coffee-rails', '~> 4.0.0'
46 46
 gem 'daemons', '~> 1.1.9'
47 47
 gem 'delayed_job', '~> 4.0.0'
48 48
 gem 'delayed_job_active_record', '~> 4.0.0'
49
-gem 'devise', '~> 3.2.4'
49
+gem 'devise', '~> 3.4.0'
50 50
 gem 'em-http-request', '~> 1.1.2'
51 51
 gem 'faraday', '~> 0.9.0'
52 52
 gem 'faraday_middleware'

+ 5 - 2
Gemfile.lock

@@ -82,10 +82,11 @@ GEM
82 82
       delayed_job (>= 3.0, < 4.1)
83 83
     delorean (2.1.0)
84 84
       chronic
85
-    devise (3.2.4)
85
+    devise (3.4.0)
86 86
       bcrypt (~> 3.0)
87 87
       orm_adapter (~> 0.1)
88 88
       railties (>= 3.2.6, < 5)
89
+      responders
89 90
       thread_safe (~> 0.1)
90 91
       warden (~> 1.2.3)
91 92
     diff-lcs (1.2.5)
@@ -258,6 +259,8 @@ GEM
258 259
     rdoc (4.1.1)
259 260
       json (~> 1.4)
260 261
     ref (1.0.5)
262
+    responders (1.1.1)
263
+      railties (>= 3.2, < 4.2)
261 264
     rest-client (1.6.8)
262 265
       mime-types (~> 1.16)
263 266
       rdoc (>= 2.4.2)
@@ -414,7 +417,7 @@ DEPENDENCIES
414 417
   delayed_job (~> 4.0.0)
415 418
   delayed_job_active_record (~> 4.0.0)
416 419
   delorean
417
-  devise (~> 3.2.4)
420
+  devise (~> 3.4.0)
418 421
   dotenv-deployment
419 422
   dotenv-rails
420 423
   em-http-request (~> 1.1.2)

+ 4 - 4
app/views/devise/confirmations/new.html.erb

@@ -4,18 +4,18 @@
4 4
 
5 5
       <h2>Resend confirmation instructions</h2>
6 6
 
7
-      <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post, :class => 'form-horizontal' }) do |f| %>
7
+      <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post, class: 'form-horizontal' }) do |f| %>
8 8
         <%= devise_error_messages! %>
9 9
 
10 10
         <div class="form-group">
11 11
           <%= f.label :email %>
12
-          <%= f.email_field :email, :class => 'form-control' %>
12
+          <%= f.email_field :email, autofocus: true, class: 'form-control' %>
13 13
         </div>
14 14
 
15
-        <%= f.submit "Resend confirmation instructions", :class => "btn btn-primary" %>
15
+        <%= f.submit "Resend confirmation instructions", class: "btn btn-primary" %>
16 16
       <% end %>
17 17
 
18 18
       <%= render "devise/shared/links" %>
19 19
     </div>
20 20
   </div>
21
-</div>
21
+</div>

+ 2 - 2
app/views/devise/mailer/confirmation_instructions.html.erb

@@ -1,5 +1,5 @@
1
-<p>Welcome <%= @resource.email %>!</p>
1
+<p>Welcome <%= @email %>!</p>
2 2
 
3 3
 <p>You can confirm your account email through the link below:</p>
4 4
 
5
-<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
5
+<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>

+ 2 - 2
app/views/devise/mailer/reset_password_instructions.html.erb

@@ -1,8 +1,8 @@
1 1
 <p>Hello <%= @resource.email %>!</p>
2 2
 
3
-<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
3
+<p>Someone has requested a link to change your password. You can do this through the link below.</p>
4 4
 
5
-<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
5
+<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
6 6
 
7 7
 <p>If you didn't request this, please ignore this email.</p>
8 8
 <p>Your password won't change until you access the link above and create a new one.</p>

+ 2 - 2
app/views/devise/mailer/unlock_instructions.html.erb

@@ -1,7 +1,7 @@
1 1
 <p>Hello <%= @resource.email %>!</p>
2 2
 
3
-<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
3
+<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
4 4
 
5 5
 <p>Click the link below to unlock your account:</p>
6 6
 
7
-<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
7
+<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>

+ 7 - 7
app/views/devise/passwords/edit.html.erb

@@ -4,26 +4,26 @@
4 4
       <div class='well'>
5 5
         <h2>Change your password</h2>
6 6
 
7
-        <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put, :class => 'form-horizontal' }) do |f| %>
7
+        <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |f| %>
8 8
           <%= devise_error_messages! %>
9 9
           <%= f.hidden_field :reset_password_token %>
10 10
 
11 11
           <div class="control-group">
12
-            <%= f.label :password, "New password", :class => 'control-label' %>
12
+            <%= f.label :password, "New password", class: 'control-label' %>
13 13
             <div class="controls">
14
-              <%= f.password_field :password, :class => 'span4' %>
14
+              <%= f.password_field :password, autofocus: true, autocomplete: "off", class: 'span4' %>
15 15
             </div>
16 16
           </div>
17 17
 
18 18
           <div class="control-group">
19
-            <%= f.label :password_confirmation, "Confirm new password", :class => 'control-label' %>
19
+            <%= f.label :password_confirmation, "Confirm new password" %>
20 20
             <div class="controls">
21
-              <%= f.password_field :password_confirmation, :class => 'span4' %>
21
+              <%= f.password_field :password_confirmation, autocomplete: "off", class: 'span4' %>
22 22
             </div>
23 23
           </div>
24 24
 
25 25
           <div class='form-actions'>
26
-            <%= f.submit "Change my password", :class => "btn btn-primary" %>
26
+            <%= f.submit "Change my password", class: "btn btn-primary" %>
27 27
           </div>
28 28
         <% end %>
29 29
 
@@ -31,4 +31,4 @@
31 31
       </div>
32 32
     </div>
33 33
   </div>
34
-</div>
34
+</div>

+ 4 - 4
app/views/devise/passwords/new.html.erb

@@ -3,19 +3,19 @@
3 3
     <div class='well'>
4 4
       <h2>Forgot your password?</h2>
5 5
 
6
-      <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, :class => 'form-horizontal' }) do |f| %>
6
+      <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post, class: 'form-horizontal' }) do |f| %>
7 7
         <%= devise_error_messages! %>
8 8
 
9 9
         <div class="form-group">
10 10
           <%= f.label :login, :class => 'col-md-2 col-md-offset-2 control-label' %>
11 11
           <div class="col-md-6">
12
-            <%= f.text_field :login, :class => 'form-control' %>
12
+            <%= f.text_field :login, autofocus: true, :class => 'form-control' %>
13 13
           </div>
14 14
         </div>
15 15
 
16 16
         <div class="form-group">
17 17
           <div class="col-md-offset-4 col-md-10">
18
-            <%= f.submit "Send me reset password instructions", :class => "btn btn-primary" %>
18
+            <%= f.submit "Send me reset password instructions", class: "btn btn-primary" %>
19 19
           </div>
20 20
         </div>
21 21
       <% end %>
@@ -25,4 +25,4 @@
25 25
       <%= render "devise/shared/links" %>
26 26
     </div>
27 27
   </div>
28
-</div>
28
+</div>

+ 22 - 18
app/views/devise/registrations/edit.html.erb

@@ -5,66 +5,70 @@
5 5
 
6 6
         <h2>Edit <%= resource_name.to_s.humanize %></h2>
7 7
 
8
-        <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-horizontal' }) do |f| %>
8
+        <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |f| %>
9 9
           <%= devise_error_messages! %>
10 10
 
11 11
           <div class="form-group">
12
-            <%= f.label :email, :class => 'col-md-4 control-label' %>
12
+            <%= f.label :email, class: 'col-md-4 control-label' %>
13 13
             <div class="col-md-6">
14
-              <%= f.email_field :email, :class => 'form-control' %>
14
+              <%= f.email_field :email, autofocus: true, class: 'form-control' %>
15 15
             </div>
16 16
           </div>
17 17
 
18
+          <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
19
+            <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
20
+          <% end %>
21
+
18 22
           <div class="form-group">
19
-            <%= f.label :username, :class => 'col-md-4 control-label' %>
23
+            <%= f.label :username, class: 'col-md-4 control-label' %>
20 24
             <div class="col-md-6">
21
-              <%= f.text_field :username, :class => 'form-control' %>
25
+              <%= f.text_field :username, class: 'form-control' %>
22 26
             </div>
23 27
           </div>
24 28
 
25 29
           <div class="form-group">
26
-            <%= f.label :current_password, :class => 'col-md-4 control-label' %>
30
+            <%= f.label :current_password, class: 'col-md-4 control-label' %>
27 31
             <div class="col-md-6">
28
-              <%= f.password_field :current_password, :class => 'form-control' %>
32
+              <%= f.password_field :current_password, class: 'form-control' %>
29 33
               <span class='help-inline'>We need your current password to confirm your changes.</span>
30 34
             </div>
31 35
           </div>
32
-          
36
+
33 37
           <div class="form-group">
34 38
             <div class="col-md-offset-4 col-md-10">
35
-              <%= f.submit "Update", :class => "btn btn-primary" %>
39
+              <%= f.submit "Update", class: "btn btn-primary" %>
36 40
             </div>
37 41
           </div>
38 42
         <% end %>
39 43
 
40 44
         <h3>Change password</h3>
41
-        <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-horizontal' }) do |f| %>
45
+        <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |f| %>
42 46
           <%= devise_error_messages! %>
43 47
           <div class="form-group">
44
-            <%= f.label :current_password, :class => 'col-md-4 control-label' %>
48
+            <%= f.label :current_password, class: 'col-md-4 control-label' %>
45 49
             <div class="col-md-6">
46
-              <%= f.password_field :current_password, :class => 'form-control' %>
50
+              <%= f.password_field :current_password, class: 'form-control' %>
47 51
               <span class='help-inline'>We need your current password to confirm your changes.</span>
48 52
             </div>
49 53
           </div>
50 54
 
51 55
           <div class="form-group">
52
-            <%= f.label :password, :class => 'col-md-4 control-label' %>
56
+            <%= f.label :password, class: 'col-md-4 control-label' %>
53 57
             <div class="col-md-6">
54
-              <%= f.password_field :password, :autocomplete => "off", :class => 'form-control' %>
58
+              <%= f.password_field :password, autocomplete: "off", class: 'form-control' %>
55 59
             </div>
56 60
           </div>
57 61
 
58 62
           <div class="form-group">
59
-            <%= f.label :password_confirmation, :class => 'col-md-4 control-label' %>
63
+            <%= f.label :password_confirmation, class: 'col-md-4 control-label' %>
60 64
             <div class="col-md-6">
61
-              <%= f.password_field :password_confirmation, :class => 'form-control' %>
65
+              <%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control' %>
62 66
             </div>
63 67
           </div>
64 68
 
65 69
           <div class="form-group">
66 70
             <div class="col-md-offset-4 col-md-10">
67
-              <%= f.submit "Update", :class => "btn btn-primary" %>
71
+              <%= f.submit "Update", class: "btn btn-primary" %>
68 72
             </div>
69 73
           </div>
70 74
 
@@ -74,7 +78,7 @@
74 78
 
75 79
         <h3>Cancel my account</h3>
76 80
 
77
-        <p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>
81
+        <p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
78 82
 
79 83
         <%= link_to "Back", :back %>
80 84
       </div>

+ 14 - 13
app/views/devise/registrations/new.html.erb

@@ -3,9 +3,9 @@
3 3
     <div class='col-md-8 col-md-offset-2'>
4 4
       <div class='well'>
5 5
 
6
-        <h2>Sign Up</h2>
6
+        <h2>Sign up</h2>
7 7
 
8
-        <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => 'form-horizontal' }) do |f| %>
8
+        <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: 'form-horizontal' }) do |f| %>
9 9
           <%= devise_error_messages! %>
10 10
           <% if ENV['ON_HEROKU'] && User.count.zero? %>
11 11
           <div class="heroku-instructions">
@@ -31,44 +31,45 @@ bin/setup_heroku
31 31
           <% end %>
32 32
 
33 33
           <div class="form-group">
34
-            <%= f.label :invitation_code, :class => 'col-md-4 control-label' %>
34
+            <%= f.label :invitation_code, class: 'col-md-4 control-label' %>
35 35
             <div class="col-md-6">
36
-              <%= f.text_field :invitation_code, :class => 'form-control' %>
36
+              <%= f.text_field :invitation_code, class: 'form-control' %>
37 37
               <span class="help-inline">We are not yet open to the public.  If you have an invitation code, please enter it here.</span>
38 38
             </div>
39 39
           </div>
40 40
 
41 41
           <div class="form-group">
42
-            <%= f.label :email, :class => 'col-md-4 control-label' %>
42
+            <%= f.label :email, class: 'col-md-4 control-label' %>
43 43
             <div class="col-md-6">
44
-              <%= f.email_field :email, :class => 'form-control' %>
44
+              <%= f.email_field :email, autofocus: true, class: 'form-control' %>
45 45
             </div>
46 46
           </div>
47 47
 
48 48
           <div class="form-group">
49
-            <%= f.label :username, :class => 'col-md-4 control-label' %>
49
+            <%= f.label :username, class: 'col-md-4 control-label' %>
50 50
             <div class="col-md-6">
51
-              <%= f.text_field :username, :class => 'form-control' %>
51
+              <%= f.text_field :username, class: 'form-control' %>
52 52
             </div>
53 53
           </div>
54 54
 
55 55
           <div class="form-group">
56
-            <%= f.label :password, :class => 'col-md-4 control-label' %>
56
+            <%= f.label :password, class: 'col-md-4 control-label' %>
57 57
             <div class="col-md-6">
58
-              <%= f.password_field :password, :autocomplete => "off", :class => 'form-control' %>
58
+              <%= f.password_field :password, autocomplete: "off", class: 'form-control' %>
59
+              <% if @validatable %><span class="help-inline"><%= @minimum_password_length %> characters minimum.</span><% end %>
59 60
             </div>
60 61
           </div>
61 62
 
62 63
           <div class="form-group">
63
-            <%= f.label :password_confirmation, :class => 'col-md-4 control-label' %>
64
+            <%= f.label :password_confirmation, class: 'col-md-4 control-label' %>
64 65
             <div class="col-md-6">
65
-              <%= f.password_field :password_confirmation, :class => 'form-control' %>
66
+              <%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control' %>
66 67
             </div>
67 68
           </div>
68 69
 
69 70
           <div class="form-group">
70 71
             <div class="col-md-offset-4 col-md-10">
71
-              <%= f.submit "Sign Up", :class => "btn btn-primary" %>
72
+              <%= f.submit "Sign up", class: "btn btn-primary" %>
72 73
             </div>
73 74
           </div>
74 75
 

+ 10 - 10
app/views/devise/sessions/new.html.erb

@@ -2,29 +2,29 @@
2 2
   <div class='col-md-6 col-md-offset-3'>
3 3
     <div class='well'>
4 4
 
5
-      <h2>Sign in</h2>
5
+      <h2>Log in</h2>
6 6
 
7
-      <%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => 'form-horizontal', :role => 'form'}) do |f| %>
7
+      <%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: 'form-horizontal', role: 'form'}) do |f| %>
8 8
         <div class="form-group">
9
-          <%= f.label :login, :class => 'col-md-2 col-md-offset-2 control-label' %>
9
+          <%= f.label :login, class: 'col-md-2 col-md-offset-2 control-label' %>
10 10
           <div class="col-md-6">
11
-            <%= f.text_field :login, :class => 'form-control' %>
11
+            <%= f.text_field :login, autofocus: true, class: 'form-control' %>
12 12
           </div>
13 13
         </div>
14 14
 
15 15
         <div class="form-group">
16
-          <%= f.label :password, :class => 'col-md-2 col-md-offset-2 control-label' %>
16
+          <%= f.label :password, class: 'col-md-2 col-md-offset-2 control-label' %>
17 17
           <div class="col-md-6">
18
-            <%= f.password_field :password, :class => 'form-control' %>
18
+            <%= f.password_field :password, class: 'form-control' %>
19 19
           </div>
20 20
         </div>
21 21
 
22 22
         <div class="form-group">
23 23
           <div class="col-md-offset-4 col-md-10">
24
-            <% if devise_mapping.rememberable? %>
24
+            <% if devise_mapping.rememberable? -%>
25 25
               <div class="checkbox">
26 26
                 <label>
27
-                  <%= f.check_box :remember_me %> Remember me
27
+                  <%= f.check_box :remember_me %> <%= f.label :remember_me %>
28 28
                 </label>
29 29
               </div>
30 30
             <% end -%>
@@ -33,7 +33,7 @@
33 33
 
34 34
         <div class="form-group">
35 35
           <div class="col-md-offset-4 col-md-10">
36
-            <%= f.submit "Sign in", :class => "btn btn-default" %>
36
+            <%= f.submit "Log in", class: "btn btn-default" %>
37 37
           </div>
38 38
         </div>
39 39
       <% end %>
@@ -43,4 +43,4 @@
43 43
       <%= render "devise/shared/links" %>
44 44
     </div>
45 45
   </div>
46
-</div>
46
+</div>

+ 2 - 2
app/views/devise/shared/_links.erb

@@ -1,12 +1,12 @@
1 1
 <%- if controller_name != 'sessions' %>
2
-  <%= link_to "Sign in", new_session_path(resource_name) %><br />
2
+  <%= link_to "Log in", new_session_path(resource_name) %><br />
3 3
 <% end -%>
4 4
 
5 5
 <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6 6
   <%= link_to "Sign up", new_registration_path(resource_name) %><br />
7 7
 <% end -%>
8 8
 
9
-<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
9
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
10 10
   <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
11 11
 <% end -%>
12 12
 

+ 5 - 5
app/views/devise/unlocks/new.html.erb

@@ -3,19 +3,19 @@
3 3
     <div class='well'>
4 4
       <h2>Resend unlock instructions</h2>
5 5
 
6
-      <%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post, :class => 'form-horizontal' }) do |f| %>
6
+      <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post, class: 'form-horizontal' }) do |f| %>
7 7
         <%= devise_error_messages! %>
8 8
 
9 9
         <div class="form-group">
10
-          <%= f.label :email, :class => 'col-md-2 col-md-offset-2 control-label' %>
10
+         <%= f.label :email, class: 'col-md-2 col-md-offset-2 control-label' %>
11 11
           <div class="col-md-6">
12
-            <%= f.text_field :email, :class => 'form-control' %>
12
+            <%= f.email_field :email, autofocus: true, class: 'form-control' %>
13 13
           </div>
14 14
         </div>
15 15
 
16 16
         <div class="form-group">
17 17
           <div class="col-md-offset-4 col-md-10">
18
-            <%= f.submit "Resend unlock instructions", :class => "btn btn-primary" %>
18
+            <%= f.submit "Resend unlock instructions", class: "btn btn-primary" %>
19 19
           </div>
20 20
         </div>
21 21
       <% end %>
@@ -25,4 +25,4 @@
25 25
       <%= render "devise/shared/links" %>
26 26
     </div>
27 27
   </div>
28
-</div>
28
+</div>

+ 47 - 28
config/initializers/devise.rb

@@ -5,10 +5,10 @@ Devise.setup do |config|
5 5
   # Configure the e-mail address which will be shown in Devise::Mailer,
6 6
   # note that it will be overwritten if you use your own mailer class
7 7
   # with default "from" parameter.
8
-  config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
8
+  config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
9 9
 
10 10
   # Configure the class responsible to send e-mails.
11
-  # config.mailer = "Devise::Mailer"
11
+  # config.mailer = 'Devise::Mailer'
12 12
 
13 13
   # ==> ORM configuration
14 14
   # Load and configure the ORM. Supports :active_record (default) and
@@ -49,17 +49,18 @@ Devise.setup do |config|
49 49
   # enable it only for database (email + password) authentication.
50 50
   # config.params_authenticatable = true
51 51
 
52
-  # Tell if authentication through HTTP Basic Auth is enabled. False by default.
52
+  # Tell if authentication through HTTP Auth is enabled. False by default.
53 53
   # It can be set to an array that will enable http authentication only for the
54
-  # given strategies, for example, `config.http_authenticatable = [:token]` will
55
-  # enable it only for token authentication.
54
+  # given strategies, for example, `config.http_authenticatable = [:database]` will
55
+  # enable it only for database authentication. The supported strategies are:
56
+  # :database      = Support basic authentication with authentication key + password
56 57
   # config.http_authenticatable = false
57 58
 
58
-  # If http headers should be returned for AJAX requests. True by default.
59
+  # If 401 status code should be returned for AJAX requests. True by default.
59 60
   # config.http_authenticatable_on_xhr = true
60 61
 
61
-  # The realm used in Http Basic Authentication. "Application" by default.
62
-  # config.http_authentication_realm = "Application"
62
+  # The realm used in Http Basic Authentication. 'Application' by default.
63
+  # config.http_authentication_realm = 'Application'
63 64
 
64 65
   # It will change confirmation, password recovery and other workflows
65 66
   # to behave the same regardless if the e-mail provided was right or wrong.
@@ -67,10 +68,10 @@ Devise.setup do |config|
67 68
   # config.paranoid = true
68 69
 
69 70
   # By default Devise will store the user in session. You can skip storage for
70
-  # :http_auth and :token_auth by adding those symbols to the array below.
71
+  # particular strategies by setting this option.
71 72
   # Notice that if you are skipping storage for all authentication paths, you
72 73
   # may want to disable generating routes to Devise's sessions controller by
73
-  # passing :skip => :sessions to `devise_for` in your config/routes.rb
74
+  # passing skip: :sessions to `devise_for` in your config/routes.rb
74 75
   config.skip_session_storage = [:http_auth]
75 76
 
76 77
   # By default, Devise cleans up the CSRF token on authentication to
@@ -85,7 +86,9 @@ Devise.setup do |config|
85 86
   #
86 87
   # Limiting the stretches to just one in testing will increase the performance of
87 88
   # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
88
-  # a value less than 10 in other environments.
89
+  # a value less than 10 in other environments. Note that, for bcrypt (the default
90
+  # encryptor), the cost increases exponentially with the number of stretches (e.g.
91
+  # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
89 92
   config.stretches = Rails.env.test? ? 1 : 10
90 93
 
91 94
   # Setup a pepper to generate the encrypted password.
@@ -93,16 +96,24 @@ Devise.setup do |config|
93 96
 
94 97
   # ==> Configuration for :confirmable
95 98
   # A period that the user is allowed to access the website even without
96
-  # confirming his account. For instance, if set to 2.days, the user will be
97
-  # able to access the website for two days without confirming his account,
99
+  # confirming their account. For instance, if set to 2.days, the user will be
100
+  # able to access the website for two days without confirming their account,
98 101
   # access will be blocked just in the third day. Default is 0.days, meaning
99
-  # the user cannot access the website without confirming his account.
102
+  # the user cannot access the website without confirming their account.
100 103
   # config.allow_unconfirmed_access_for = 2.days
101 104
 
105
+  # A period that the user is allowed to confirm their account before their
106
+  # token becomes invalid. For example, if set to 3.days, the user can confirm
107
+  # their account within 3 days after the mail was sent, but on the fourth day
108
+  # their account can't be confirmed with the token any more.
109
+  # Default is nil, meaning there is no restriction on how long a user can take
110
+  # before confirming their account.
111
+  # config.confirm_within = 3.days
112
+
102 113
   # If true, requires any email changes to be confirmed (exactly the same way as
103 114
   # initial account confirmation) to be applied. Requires additional unconfirmed_email
104
-  # db field (see migrations). Until confirmed new email is stored in
105
-  # unconfirmed email column, and copied to email column on successful confirmation.
115
+  # db field (see migrations). Until confirmed, new email is stored in
116
+  # unconfirmed_email column, and copied to email column on successful confirmation.
106 117
   config.reconfirmable = true
107 118
 
108 119
   # Defines which key will be used when confirming an account
@@ -112,23 +123,26 @@ Devise.setup do |config|
112 123
   # The time the user will be remembered without asking for credentials again.
113 124
   config.remember_for = 4.weeks
114 125
 
126
+  # Invalidates all the remember me tokens when the user signs out.
127
+  config.expire_all_remember_me_on_sign_out = true
128
+
115 129
   # If true, extends the user's remember period when remembered via cookie.
116 130
   # config.extend_remember_period = false
117 131
 
118 132
   # Options to be passed to the created cookie. For instance, you can set
119
-  # :secure => true in order to force SSL only cookies.
133
+  # secure: true in order to force SSL only cookies.
120 134
   if Rails.env.production?
121
-    config.rememberable_options = { :secure => true }
135
+    config.rememberable_options = { secure: true }
122 136
   else
123 137
     config.rememberable_options = { }
124 138
   end
125 139
 
126 140
   # ==> Configuration for :validatable
127
-  # Range for password length. Default is 6..128.
128
-  # config.password_length = 6..128
141
+  # Range for password length.
142
+  config.password_length = 8..128
129 143
 
130 144
   # Email regex used to validate email formats. It simply asserts that
131
-  # an one (and only one) @ exists in the given string. This is mainly
145
+  # one (and only one) @ exists in the given string. This is mainly
132 146
   # to give user feedback and not to assert the e-mail validity.
133 147
   # config.email_regexp = /\A[^@]+@[^@]+\z/
134 148
 
@@ -136,7 +150,7 @@ Devise.setup do |config|
136 150
   # The time you want to timeout the user session without activity. After this
137 151
   # time the user will be asked for credentials again. Default is 30 minutes.
138 152
   # config.timeout_in = 30.minutes
139
-  
153
+
140 154
   # If true, expires auth token on session timeout.
141 155
   # config.expire_auth_token_on_timeout = false
142 156
 
@@ -163,6 +177,9 @@ Devise.setup do |config|
163 177
   # Time interval to unlock the account if :time is enabled as unlock_strategy.
164 178
   config.unlock_in = 1.hour
165 179
 
180
+  # Warn on the last attempt before the account is locked.
181
+  # config.last_attempt_warning = true
182
+
166 183
   # ==> Configuration for :recoverable
167 184
   #
168 185
   # Defines which key will be used when recovering the password for an account
@@ -178,7 +195,9 @@ Devise.setup do |config|
178 195
   # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
179 196
   # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
180 197
   # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
181
-  # REST_AUTH_SITE_KEY to pepper)
198
+  # REST_AUTH_SITE_KEY to pepper).
199
+  #
200
+  # Require the `devise-encryptable` gem when using anything other than bcrypt
182 201
   # config.encryptor = :sha512
183 202
 
184 203
   # ==> Scopes configuration
@@ -204,7 +223,7 @@ Devise.setup do |config|
204 223
   # should add them to the navigational formats lists.
205 224
   #
206 225
   # The "*/*" below is required to match Internet Explorer requests.
207
-  # config.navigational_formats = ["*/*", :html]
226
+  # config.navigational_formats = ['*/*', :html]
208 227
 
209 228
   # The default HTTP method used to sign out a resource. Default is :delete.
210 229
   config.sign_out_via = :get
@@ -212,7 +231,7 @@ Devise.setup do |config|
212 231
   # ==> OmniAuth
213 232
   # Add a new OmniAuth provider. Check the wiki for more information on setting
214 233
   # up on your models and hooks.
215
-  # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
234
+  # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
216 235
   if defined?(OmniAuth::Strategies::Twitter) &&
217 236
      (key = ENV["TWITTER_OAUTH_KEY"]).present? &&
218 237
      (secret = ENV["TWITTER_OAUTH_SECRET"]).present?
@@ -243,7 +262,7 @@ Devise.setup do |config|
243 262
   #
244 263
   # config.warden do |manager|
245 264
   #   manager.intercept_401 = false
246
-  #   manager.default_strategies(:scope => :user).unshift :some_external_strategy
265
+  #   manager.default_strategies(scope: :user).unshift :some_external_strategy
247 266
   # end
248 267
 
249 268
   # ==> Mountable engine configurations
@@ -251,13 +270,13 @@ Devise.setup do |config|
251 270
   # is mountable, there are some extra configurations to be taken into account.
252 271
   # The following options are available, assuming the engine is mounted as:
253 272
   #
254
-  #     mount MyEngine, at: "/my_engine"
273
+  #     mount MyEngine, at: '/my_engine'
255 274
   #
256 275
   # The router that invoked `devise_for`, in the example above, would be:
257 276
   # config.router_name = :my_engine
258 277
   #
259 278
   # When using omniauth, Devise cannot automatically set Omniauth path,
260 279
   # so you need to do it manually. For the users scope, it would be:
261
-  # config.omniauth_path_prefix = "/my_engine/users/auth"
280
+  # config.omniauth_path_prefix = '/my_engine/users/auth'
262 281
   config.omniauth_path_prefix = "/auth"
263 282
 end

+ 54 - 52
config/locales/devise.en.yml

@@ -1,63 +1,65 @@
1 1
 # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2 2
 
3 3
 en:
4
+  devise:
5
+    confirmations:
6
+      confirmed: "Your email address has been successfully confirmed."
7
+      send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
+      send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
+    failure:
10
+      already_authenticated: "You are already signed in."
11
+      inactive: "Your account is not activated yet."
12
+      invalid: "Invalid %{authentication_keys} or password."
13
+      locked: "Your account is locked."
14
+      last_attempt: "You have one more attempt before your account is locked."
15
+      not_found_in_database: "Invalid %{authentication_keys} or password."
16
+      timeout: "Your session expired. Please sign in again to continue."
17
+      unauthenticated: "You need to sign in or sign up before continuing."
18
+      unconfirmed: "You have to confirm your email address before continuing."
19
+    mailer:
20
+      confirmation_instructions:
21
+        subject: "Confirmation instructions"
22
+      reset_password_instructions:
23
+        subject: "Reset password instructions"
24
+      unlock_instructions:
25
+        subject: "Unlock instructions"
26
+    omniauth_callbacks:
27
+      failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28
+      success: "Successfully authenticated from %{kind} account."
29
+    omniauth_providers:
30
+      twitter: "Twitter"
31
+      tumblr: "Tumblr"
32
+      github: "GitHub"
33
+      37signals: "37Signals (Basecamp)"
34
+    passwords:
35
+      no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
36
+      send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
37
+      send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
38
+      updated: "Your password has been changed successfully. You are now signed in."
39
+      updated_not_active: "Your password has been changed successfully."
40
+    registrations:
41
+      destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
42
+      signed_up: "Welcome! You have signed up successfully."
43
+      signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
44
+      signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
45
+      signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
46
+      update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
47
+      updated: "Your account has been updated successfully."
48
+    sessions:
49
+      signed_in: "Signed in successfully."
50
+      signed_out: "Signed out successfully."
51
+      already_signed_out: "Signed out successfully."
52
+    unlocks:
53
+      send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54
+      send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55
+      unlocked: "Your account has been unlocked successfully. Please sign in to continue."
4 56
   errors:
5 57
     messages:
58
+      already_confirmed: "was already confirmed, please try signing in"
59
+      confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
6 60
       expired: "has expired, please request a new one"
7 61
       not_found: "not found"
8
-      already_confirmed: "was already confirmed, please try signing in"
9 62
       not_locked: "was not locked"
10 63
       not_saved:
11 64
         one: "1 error prohibited this %{resource} from being saved:"
12 65
         other: "%{count} errors prohibited this %{resource} from being saved:"
13
-
14
-  devise:
15
-    failure:
16
-      already_authenticated: 'You are already signed in.'
17
-      unauthenticated: 'You need to sign in or sign up before continuing.'
18
-      unconfirmed: 'You have to confirm your account before continuing.'
19
-      locked: 'Your account is locked.'
20
-      invalid: 'Invalid login or password.'
21
-      invalid_token: 'Invalid authentication token.'
22
-      timeout: 'Your session expired, please sign in again to continue.'
23
-      inactive: 'Your account was not activated yet.'
24
-    sessions:
25
-      signed_in: 'Signed in successfully.'
26
-      signed_out: 'Signed out successfully.'
27
-    passwords:
28
-      send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
29
-      updated: 'Your password was changed successfully. You are now signed in.'
30
-      updated_not_active: 'Your password was changed successfully.'
31
-      send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
32
-      no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
33
-    confirmations:
34
-      send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
35
-      send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
36
-      confirmed: 'Your account was successfully confirmed. You are now signed in.'
37
-    registrations:
38
-      signed_up: 'Welcome! You have signed up successfully.'
39
-      signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
40
-      signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
41
-      signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
42
-      updated: 'You updated your account successfully.'
43
-      update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
44
-      destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
45
-    unlocks:
46
-      send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
47
-      unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
48
-      send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
49
-    omniauth_callbacks:
50
-      success: 'Successfully authenticated from %{kind} account.'
51
-      failure: 'Could not authenticate you from %{kind} because "%{reason}".'
52
-    omniauth_providers:
53
-      twitter: 'Twitter'
54
-      tumblr: 'Tumblr'
55
-      github: 'GitHub'
56
-      37signals: '37Signals (Basecamp)'
57
-    mailer:
58
-      confirmation_instructions:
59
-        subject: 'Confirmation instructions'
60
-      reset_password_instructions:
61
-        subject: 'Reset password instructions'
62
-      unlock_instructions:
63
-        subject: 'Unlock Instructions'