devise 3.2.0 → 3.3.0

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.

Potentially problematic release.


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

Files changed (187) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +18 -3
  3. data/CHANGELOG.md +82 -9
  4. data/CONTRIBUTING.md +2 -2
  5. data/Gemfile +7 -9
  6. data/Gemfile.lock +102 -96
  7. data/MIT-LICENSE +1 -1
  8. data/README.md +94 -42
  9. data/Rakefile +1 -1
  10. data/app/controllers/devise/confirmations_controller.rb +5 -3
  11. data/app/controllers/devise/omniauth_callbacks_controller.rb +2 -2
  12. data/app/controllers/devise/passwords_controller.rb +5 -3
  13. data/app/controllers/devise/registrations_controller.rb +26 -10
  14. data/app/controllers/devise/sessions_controller.rb +39 -14
  15. data/app/controllers/devise/unlocks_controller.rb +4 -2
  16. data/app/controllers/devise_controller.rb +6 -6
  17. data/app/helpers/devise_helper.rb +2 -2
  18. data/app/views/devise/confirmations/new.html.erb +2 -2
  19. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  20. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  21. data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
  22. data/app/views/devise/passwords/edit.html.erb +3 -3
  23. data/app/views/devise/passwords/new.html.erb +2 -2
  24. data/app/views/devise/registrations/edit.html.erb +6 -6
  25. data/app/views/devise/registrations/new.html.erb +5 -5
  26. data/app/views/devise/sessions/new.html.erb +5 -5
  27. data/app/views/devise/shared/_links.erb +1 -1
  28. data/app/views/devise/unlocks/new.html.erb +2 -2
  29. data/config/locales/en.yml +17 -16
  30. data/devise.gemspec +2 -2
  31. data/gemfiles/{Gemfile.rails-3.2.x → Gemfile.rails-3.2-stable} +8 -10
  32. data/gemfiles/Gemfile.rails-3.2-stable.lock +166 -0
  33. data/gemfiles/Gemfile.rails-4.0-stable +29 -0
  34. data/gemfiles/Gemfile.rails-4.0-stable.lock +162 -0
  35. data/gemfiles/Gemfile.rails-head +32 -0
  36. data/gemfiles/Gemfile.rails-head.lock +190 -0
  37. data/lib/devise/controllers/helpers.rb +84 -29
  38. data/lib/devise/controllers/rememberable.rb +3 -3
  39. data/lib/devise/controllers/scoped_views.rb +1 -1
  40. data/lib/devise/controllers/sign_in_out.rb +9 -10
  41. data/lib/devise/controllers/store_location.rb +56 -0
  42. data/lib/devise/controllers/url_helpers.rb +3 -1
  43. data/lib/devise/failure_app.rb +12 -10
  44. data/lib/devise/hooks/activatable.rb +5 -6
  45. data/lib/devise/hooks/csrf_cleaner.rb +3 -1
  46. data/lib/devise/hooks/lockable.rb +1 -1
  47. data/lib/devise/hooks/proxy.rb +2 -2
  48. data/lib/devise/hooks/rememberable.rb +2 -2
  49. data/lib/devise/hooks/timeoutable.rb +10 -3
  50. data/lib/devise/hooks/trackable.rb +1 -1
  51. data/lib/devise/mailers/helpers.rb +8 -8
  52. data/lib/devise/mapping.rb +4 -1
  53. data/lib/devise/models/authenticatable.rb +5 -5
  54. data/lib/devise/models/confirmable.rb +14 -14
  55. data/lib/devise/models/database_authenticatable.rb +18 -5
  56. data/lib/devise/models/lockable.rb +14 -11
  57. data/lib/devise/models/omniauthable.rb +1 -1
  58. data/lib/devise/models/recoverable.rb +23 -7
  59. data/lib/devise/models/rememberable.rb +6 -6
  60. data/lib/devise/models/timeoutable.rb +2 -2
  61. data/lib/devise/models/trackable.rb +5 -2
  62. data/lib/devise/models/validatable.rb +6 -6
  63. data/lib/devise/modules.rb +10 -10
  64. data/lib/devise/omniauth/url_helpers.rb +2 -2
  65. data/lib/devise/orm/active_record.rb +1 -1
  66. data/lib/devise/orm/mongoid.rb +1 -1
  67. data/lib/devise/rails/routes.rb +107 -78
  68. data/lib/devise/rails.rb +7 -1
  69. data/lib/devise/strategies/authenticatable.rb +11 -4
  70. data/lib/devise/strategies/base.rb +1 -1
  71. data/lib/devise/strategies/database_authenticatable.rb +7 -4
  72. data/lib/devise/test_helpers.rb +2 -2
  73. data/lib/devise/time_inflector.rb +2 -2
  74. data/lib/devise/version.rb +1 -1
  75. data/lib/devise.rb +15 -10
  76. data/lib/generators/active_record/devise_generator.rb +27 -10
  77. data/lib/generators/active_record/templates/migration.rb +4 -4
  78. data/lib/generators/active_record/templates/migration_existing.rb +4 -4
  79. data/lib/generators/devise/devise_generator.rb +5 -3
  80. data/lib/generators/devise/install_generator.rb +5 -0
  81. data/lib/generators/devise/views_generator.rb +31 -18
  82. data/lib/generators/mongoid/devise_generator.rb +20 -19
  83. data/lib/generators/templates/README +4 -4
  84. data/lib/generators/templates/devise.rb +20 -11
  85. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  86. data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
  87. data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
  88. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -2
  89. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
  90. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
  91. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -6
  92. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
  93. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +4 -4
  94. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -2
  95. data/script/cached-bundle +49 -0
  96. data/script/s3-put +71 -0
  97. data/test/controllers/custom_registrations_controller_test.rb +35 -0
  98. data/test/controllers/helpers_test.rb +89 -31
  99. data/test/controllers/internal_helpers_test.rb +11 -8
  100. data/test/controllers/passwords_controller_test.rb +1 -1
  101. data/test/controllers/sessions_controller_test.rb +29 -25
  102. data/test/controllers/url_helpers_test.rb +4 -4
  103. data/test/delegator_test.rb +1 -1
  104. data/test/devise_test.rb +21 -8
  105. data/test/failure_app_test.rb +61 -25
  106. data/test/generators/active_record_generator_test.rb +10 -4
  107. data/test/generators/devise_generator_test.rb +2 -2
  108. data/test/generators/mongoid_generator_test.rb +3 -3
  109. data/test/generators/views_generator_test.rb +30 -1
  110. data/test/helpers/devise_helper_test.rb +14 -13
  111. data/test/integration/authenticatable_test.rb +61 -45
  112. data/test/integration/confirmable_test.rb +95 -55
  113. data/test/integration/database_authenticatable_test.rb +16 -16
  114. data/test/integration/http_authenticatable_test.rb +12 -12
  115. data/test/integration/lockable_test.rb +43 -43
  116. data/test/integration/omniauthable_test.rb +3 -3
  117. data/test/integration/recoverable_test.rb +53 -53
  118. data/test/integration/registerable_test.rb +90 -80
  119. data/test/integration/rememberable_test.rb +15 -15
  120. data/test/integration/timeoutable_test.rb +27 -16
  121. data/test/integration/trackable_test.rb +4 -4
  122. data/test/mailers/confirmation_instructions_test.rb +7 -7
  123. data/test/mailers/reset_password_instructions_test.rb +6 -6
  124. data/test/mailers/unlock_instructions_test.rb +5 -5
  125. data/test/mapping_test.rb +3 -3
  126. data/test/models/authenticatable_test.rb +3 -3
  127. data/test/models/confirmable_test.rb +32 -32
  128. data/test/models/database_authenticatable_test.rb +32 -27
  129. data/test/models/lockable_test.rb +57 -33
  130. data/test/models/recoverable_test.rb +34 -22
  131. data/test/models/rememberable_test.rb +29 -14
  132. data/test/models/serializable_test.rb +8 -8
  133. data/test/models/timeoutable_test.rb +1 -1
  134. data/test/models/trackable_test.rb +28 -0
  135. data/test/models/validatable_test.rb +13 -13
  136. data/test/omniauth/config_test.rb +4 -4
  137. data/test/omniauth/url_helpers_test.rb +3 -3
  138. data/test/orm/mongoid.rb +1 -1
  139. data/test/parameter_sanitizer_test.rb +1 -1
  140. data/test/rails_app/app/active_record/shim.rb +1 -1
  141. data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
  142. data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
  143. data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -1
  144. data/test/rails_app/app/controllers/admins_controller.rb +1 -1
  145. data/test/rails_app/app/controllers/application_controller.rb +5 -2
  146. data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
  147. data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
  148. data/test/rails_app/app/controllers/home_controller.rb +1 -1
  149. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -1
  150. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -1
  151. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +4 -4
  152. data/test/rails_app/app/controllers/users_controller.rb +6 -6
  153. data/test/rails_app/app/mailers/users/mailer.rb +4 -4
  154. data/test/rails_app/app/mongoid/admin.rb +11 -11
  155. data/test/rails_app/app/mongoid/shim.rb +2 -2
  156. data/test/rails_app/app/mongoid/user.rb +19 -19
  157. data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
  158. data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
  159. data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
  160. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -1
  161. data/test/rails_app/app/views/home/index.html.erb +1 -1
  162. data/test/rails_app/app/views/home/join.html.erb +1 -1
  163. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -1
  164. data/test/rails_app/app/views/layouts/application.html.erb +1 -1
  165. data/test/rails_app/config/application.rb +2 -2
  166. data/test/rails_app/config/boot.rb +7 -1
  167. data/test/rails_app/config/environments/development.rb +0 -4
  168. data/test/rails_app/config/environments/production.rb +0 -4
  169. data/test/rails_app/config/initializers/devise.rb +7 -5
  170. data/test/rails_app/config/initializers/secret_token.rb +1 -1
  171. data/test/rails_app/config/routes.rb +60 -42
  172. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +7 -7
  173. data/test/rails_app/db/schema.rb +21 -17
  174. data/test/rails_app/lib/shared_admin.rb +4 -4
  175. data/test/rails_app/lib/shared_user.rb +1 -1
  176. data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
  177. data/test/routes_test.rb +72 -58
  178. data/test/support/action_controller/record_identifier.rb +10 -0
  179. data/test/support/assertions.rb +2 -3
  180. data/test/support/helpers.rb +4 -4
  181. data/test/support/integration.rb +14 -14
  182. data/test/support/mongoid.yml +6 -0
  183. data/test/test_helper.rb +2 -7
  184. data/test/test_helpers_test.rb +25 -35
  185. data/test/test_models.rb +12 -5
  186. metadata +53 -38
  187. data/gemfiles/Gemfile.rails-3.2.x.lock +0 -159
@@ -4,21 +4,21 @@ require 'generators/devise/orm_helpers'
4
4
  module ActiveRecord
5
5
  module Generators
6
6
  class DeviseGenerator < ActiveRecord::Generators::Base
7
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
8
8
 
9
9
  include Devise::Generators::OrmHelpers
10
10
  source_root File.expand_path("../templates", __FILE__)
11
11
 
12
12
  def copy_devise_migration
13
13
  if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
14
- migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}"
14
+ migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}.rb"
15
15
  else
16
- migration_template "migration.rb", "db/migrate/devise_create_#{table_name}"
16
+ migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb"
17
17
  end
18
18
  end
19
19
 
20
20
  def generate_model
21
- invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke
21
+ invoke "active_record:model", [name], migration: false unless model_exists? && behavior == :invoke
22
22
  end
23
23
 
24
24
  def inject_devise_content
@@ -39,8 +39,8 @@ module ActiveRecord
39
39
  def migration_data
40
40
  <<RUBY
41
41
  ## Database authenticatable
42
- t.string :email, :null => false, :default => ""
43
- t.string :encrypted_password, :null => false, :default => ""
42
+ t.string :email, null: false, default: ""
43
+ t.string :encrypted_password, null: false, default: ""
44
44
 
45
45
  ## Recoverable
46
46
  t.string :reset_password_token
@@ -50,11 +50,11 @@ module ActiveRecord
50
50
  t.datetime :remember_created_at
51
51
 
52
52
  ## Trackable
53
- t.integer :sign_in_count, :default => 0, :null => false
53
+ t.integer :sign_in_count, default: 0, null: false
54
54
  t.datetime :current_sign_in_at
55
55
  t.datetime :last_sign_in_at
56
- t.string :current_sign_in_ip
57
- t.string :last_sign_in_ip
56
+ t.#{ip_column} :current_sign_in_ip
57
+ t.#{ip_column} :last_sign_in_ip
58
58
 
59
59
  ## Confirmable
60
60
  # t.string :confirmation_token
@@ -63,11 +63,28 @@ module ActiveRecord
63
63
  # t.string :unconfirmed_email # Only if using reconfirmable
64
64
 
65
65
  ## Lockable
66
- # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
66
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
67
67
  # t.string :unlock_token # Only if unlock strategy is :email or :both
68
68
  # t.datetime :locked_at
69
69
  RUBY
70
70
  end
71
+
72
+ def ip_column
73
+ # Padded with spaces so it aligns nicely with the rest of the columns.
74
+ "%-8s" % (inet? ? "inet" : "string")
75
+ end
76
+
77
+ def inet?
78
+ rails4? && postgresql?
79
+ end
80
+
81
+ def rails4?
82
+ Rails.version.start_with? '4'
83
+ end
84
+
85
+ def postgresql?
86
+ ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"
87
+ end
71
88
  end
72
89
  end
73
90
  end
@@ -10,9 +10,9 @@ class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
10
10
  t.timestamps
11
11
  end
12
12
 
13
- add_index :<%= table_name %>, :email, :unique => true
14
- add_index :<%= table_name %>, :reset_password_token, :unique => true
15
- # add_index :<%= table_name %>, :confirmation_token, :unique => true
16
- # add_index :<%= table_name %>, :unlock_token, :unique => true
13
+ add_index :<%= table_name %>, :email, unique: true
14
+ add_index :<%= table_name %>, :reset_password_token, unique: true
15
+ # add_index :<%= table_name %>, :confirmation_token, unique: true
16
+ # add_index :<%= table_name %>, :unlock_token, unique: true
17
17
  end
18
18
  end
@@ -11,10 +11,10 @@ class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration
11
11
  # t.timestamps
12
12
  end
13
13
 
14
- add_index :<%= table_name %>, :email, :unique => true
15
- add_index :<%= table_name %>, :reset_password_token, :unique => true
16
- # add_index :<%= table_name %>, :confirmation_token, :unique => true
17
- # add_index :<%= table_name %>, :unlock_token, :unique => true
14
+ add_index :<%= table_name %>, :email, unique: true
15
+ add_index :<%= table_name %>, :reset_password_token, unique: true
16
+ # add_index :<%= table_name %>, :confirmation_token, unique: true
17
+ # add_index :<%= table_name %>, :unlock_token, unique: true
18
18
  end
19
19
 
20
20
  def self.down
@@ -1,3 +1,5 @@
1
+ require 'rails/generators/named_base'
2
+
1
3
  module Devise
2
4
  module Generators
3
5
  class DeviseGenerator < Rails::Generators::NamedBase
@@ -11,12 +13,12 @@ module Devise
11
13
 
12
14
  hook_for :orm
13
15
 
14
- class_option :routes, :desc => "Generate routes", :type => :boolean, :default => true
16
+ class_option :routes, desc: "Generate routes", type: :boolean, default: true
15
17
 
16
18
  def add_devise_routes
17
19
  devise_route = "devise_for :#{plural_name}"
18
- devise_route << %Q(, :class_name => "#{class_name}") if class_name.include?("::")
19
- devise_route << %Q(, :skip => :all) unless options.routes?
20
+ devise_route << %Q(, class_name: "#{class_name}") if class_name.include?("::")
21
+ devise_route << %Q(, skip: :all) unless options.routes?
20
22
  route devise_route
21
23
  end
22
24
  end
@@ -1,3 +1,4 @@
1
+ require 'rails/generators/base'
1
2
  require 'securerandom'
2
3
 
3
4
  module Devise
@@ -19,6 +20,10 @@ module Devise
19
20
  def show_readme
20
21
  readme "README" if behavior == :invoke
21
22
  end
23
+
24
+ def rails_4?
25
+ Rails::VERSION::MAJOR == 4
26
+ end
22
27
  end
23
28
  end
24
29
  end
@@ -1,3 +1,5 @@
1
+ require 'rails/generators/base'
2
+
1
3
  module Devise
2
4
  module Generators
3
5
  # Include this module in your generator to generate Devise views.
@@ -7,13 +9,14 @@ module Devise
7
9
  extend ActiveSupport::Concern
8
10
 
9
11
  included do
10
- argument :scope, :required => false, :default => nil,
11
- :desc => "The scope to copy views to"
12
+ argument :scope, required: false, default: nil,
13
+ desc: "The scope to copy views to"
12
14
 
13
15
  # Le sigh, ensure Thor won't handle opts as args
14
16
  # It should be fixed in future Rails releases
15
- class_option :form_builder, :aliases => "-b"
17
+ class_option :form_builder, aliases: "-b"
16
18
  class_option :markerb
19
+ class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (confirmations, passwords, registrations, sessions, unlocks, mailer)"
17
20
 
18
21
  public_task :copy_views
19
22
  end
@@ -26,11 +29,17 @@ module Devise
26
29
  end
27
30
 
28
31
  def copy_views
29
- view_directory :confirmations
30
- view_directory :passwords
31
- view_directory :registrations
32
- view_directory :sessions
33
- view_directory :unlocks
32
+ if options[:views]
33
+ options[:views].each do |directory|
34
+ view_directory directory.to_sym
35
+ end
36
+ else
37
+ view_directory :confirmations
38
+ view_directory :passwords
39
+ view_directory :registrations
40
+ view_directory :sessions
41
+ view_directory :unlocks
42
+ end
34
43
  end
35
44
 
36
45
  protected
@@ -83,7 +92,9 @@ module Devise
83
92
  hide!
84
93
 
85
94
  def copy_views
86
- view_directory :mailer
95
+ if !options[:views] || options[:views].include?('mailer')
96
+ view_directory :mailer
97
+ end
87
98
  end
88
99
  end
89
100
 
@@ -94,7 +105,9 @@ module Devise
94
105
  hide!
95
106
 
96
107
  def copy_views
97
- view_directory :markerb, target_path
108
+ if !options[:views] || options[:views].include?('mailer')
109
+ view_directory :markerb, target_path
110
+ end
98
111
  end
99
112
 
100
113
  def target_path
@@ -105,18 +118,18 @@ module Devise
105
118
  class ViewsGenerator < Rails::Generators::Base
106
119
  desc "Copies Devise views to your application."
107
120
 
108
- argument :scope, :required => false, :default => nil,
109
- :desc => "The scope to copy views to"
121
+ argument :scope, required: false, default: nil,
122
+ desc: "The scope to copy views to"
110
123
 
111
124
  invoke SharedViewsGenerator
112
125
 
113
- hook_for :form_builder, :aliases => "-b",
114
- :desc => "Form builder to be used",
115
- :default => defined?(SimpleForm) ? "simple_form_for" : "form_for"
126
+ hook_for :form_builder, aliases: "-b",
127
+ desc: "Form builder to be used",
128
+ default: defined?(SimpleForm) ? "simple_form_for" : "form_for"
116
129
 
117
- hook_for :markerb, :desc => "Generate markerb instead of erb mail views",
118
- :default => defined?(Markerb) ? :markerb : :erb,
119
- :type => :boolean
130
+ hook_for :markerb, desc: "Generate markerb instead of erb mail views",
131
+ default: defined?(Markerb) ? :markerb : :erb,
132
+ type: :boolean
120
133
  end
121
134
  end
122
135
  end
@@ -1,3 +1,4 @@
1
+ require 'rails/generators/named_base'
1
2
  require 'generators/devise/orm_helpers'
2
3
 
3
4
  module Mongoid
@@ -10,43 +11,43 @@ module Mongoid
10
11
  end
11
12
 
12
13
  def inject_field_types
13
- inject_into_file model_path, migration_data, :after => "include Mongoid::Document\n" if model_exists?
14
+ inject_into_file model_path, migration_data, after: "include Mongoid::Document\n" if model_exists?
14
15
  end
15
16
 
16
17
  def inject_devise_content
17
- inject_into_file model_path, model_contents, :after => "include Mongoid::Document\n" if model_exists?
18
+ inject_into_file model_path, model_contents, after: "include Mongoid::Document\n" if model_exists?
18
19
  end
19
20
 
20
21
  def migration_data
21
22
  <<RUBY
22
23
  ## Database authenticatable
23
- field :email, :type => String, :default => ""
24
- field :encrypted_password, :type => String, :default => ""
24
+ field :email, type: String, default: ""
25
+ field :encrypted_password, type: String, default: ""
25
26
 
26
27
  ## Recoverable
27
- field :reset_password_token, :type => String
28
- field :reset_password_sent_at, :type => Time
28
+ field :reset_password_token, type: String
29
+ field :reset_password_sent_at, type: Time
29
30
 
30
31
  ## Rememberable
31
- field :remember_created_at, :type => Time
32
+ field :remember_created_at, type: Time
32
33
 
33
34
  ## Trackable
34
- field :sign_in_count, :type => Integer, :default => 0
35
- field :current_sign_in_at, :type => Time
36
- field :last_sign_in_at, :type => Time
37
- field :current_sign_in_ip, :type => String
38
- field :last_sign_in_ip, :type => String
35
+ field :sign_in_count, type: Integer, default: 0
36
+ field :current_sign_in_at, type: Time
37
+ field :last_sign_in_at, type: Time
38
+ field :current_sign_in_ip, type: String
39
+ field :last_sign_in_ip, type: String
39
40
 
40
41
  ## Confirmable
41
- # field :confirmation_token, :type => String
42
- # field :confirmed_at, :type => Time
43
- # field :confirmation_sent_at, :type => Time
44
- # field :unconfirmed_email, :type => String # Only if using reconfirmable
42
+ # field :confirmation_token, type: String
43
+ # field :confirmed_at, type: Time
44
+ # field :confirmation_sent_at, type: Time
45
+ # field :unconfirmed_email, type: String # Only if using reconfirmable
45
46
 
46
47
  ## Lockable
47
- # field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
48
- # field :unlock_token, :type => String # Only if unlock strategy is :email or :both
49
- # field :locked_at, :type => Time
48
+ # field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
49
+ # field :unlock_token, type: String # Only if unlock strategy is :email or :both
50
+ # field :locked_at, type: Time
50
51
  RUBY
51
52
  end
52
53
  end
@@ -2,18 +2,18 @@
2
2
 
3
3
  Some setup you must do manually if you haven't yet:
4
4
 
5
- 1. Ensure you have defined default url options in your environments files. Here
6
- is an example of default_url_options appropriate for a development environment
5
+ 1. Ensure you have defined default url options in your environments files. Here
6
+ is an example of default_url_options appropriate for a development environment
7
7
  in config/environments/development.rb:
8
8
 
9
- config.action_mailer.default_url_options = { :host => 'localhost:3000' }
9
+ config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
10
10
 
11
11
  In production, :host should be set to the actual host of your application.
12
12
 
13
13
  2. Ensure you have defined root_url to *something* in your config/routes.rb.
14
14
  For example:
15
15
 
16
- root :to => "home#index"
16
+ root to: "home#index"
17
17
 
18
18
  3. Ensure you have flash messages in app/views/layouts/application.html.erb.
19
19
  For example:
@@ -4,7 +4,11 @@ Devise.setup do |config|
4
4
  # The secret key used by Devise. Devise uses this key to generate
5
5
  # random tokens. Changing this key will render invalid all existing
6
6
  # confirmation, reset password and unlock tokens in the database.
7
+ <% if rails_4? -%>
8
+ # config.secret_key = '<%= SecureRandom.hex(64) %>'
9
+ <% else -%>
7
10
  config.secret_key = '<%= SecureRandom.hex(64) %>'
11
+ <% end -%>
8
12
 
9
13
  # ==> Mailer Configuration
10
14
  # Configure the e-mail address which will be shown in Devise::Mailer,
@@ -76,7 +80,7 @@ Devise.setup do |config|
76
80
  # particular strategies by setting this option.
77
81
  # Notice that if you are skipping storage for all authentication paths, you
78
82
  # may want to disable generating routes to Devise's sessions controller by
79
- # passing :skip => :sessions to `devise_for` in your config/routes.rb
83
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
80
84
  config.skip_session_storage = [:http_auth]
81
85
 
82
86
  # By default, Devise cleans up the CSRF token on authentication to
@@ -91,7 +95,9 @@ Devise.setup do |config|
91
95
  #
92
96
  # Limiting the stretches to just one in testing will increase the performance of
93
97
  # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
94
- # a value less than 10 in other environments.
98
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
99
+ # encryptor), the cost increases exponentially with the number of stretches (e.g.
100
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
95
101
  config.stretches = Rails.env.test? ? 1 : 10
96
102
 
97
103
  # Setup a pepper to generate the encrypted password.
@@ -99,10 +105,10 @@ Devise.setup do |config|
99
105
 
100
106
  # ==> Configuration for :confirmable
101
107
  # A period that the user is allowed to access the website even without
102
- # confirming his account. For instance, if set to 2.days, the user will be
103
- # able to access the website for two days without confirming his account,
108
+ # confirming their account. For instance, if set to 2.days, the user will be
109
+ # able to access the website for two days without confirming their account,
104
110
  # access will be blocked just in the third day. Default is 0.days, meaning
105
- # the user cannot access the website without confirming his account.
111
+ # the user cannot access the website without confirming their account.
106
112
  # config.allow_unconfirmed_access_for = 2.days
107
113
 
108
114
  # A period that the user is allowed to confirm their account before their
@@ -115,8 +121,8 @@ Devise.setup do |config|
115
121
 
116
122
  # If true, requires any email changes to be confirmed (exactly the same way as
117
123
  # initial account confirmation) to be applied. Requires additional unconfirmed_email
118
- # db field (see migrations). Until confirmed new email is stored in
119
- # unconfirmed email column, and copied to email column on successful confirmation.
124
+ # db field (see migrations). Until confirmed, new email is stored in
125
+ # unconfirmed_email column, and copied to email column on successful confirmation.
120
126
  config.reconfirmable = true
121
127
 
122
128
  # Defines which key will be used when confirming an account
@@ -126,15 +132,18 @@ Devise.setup do |config|
126
132
  # The time the user will be remembered without asking for credentials again.
127
133
  # config.remember_for = 2.weeks
128
134
 
135
+ # Invalidates all the remember me tokens when the user signs out.
136
+ config.expire_all_remember_me_on_sign_out = true
137
+
129
138
  # If true, extends the user's remember period when remembered via cookie.
130
139
  # config.extend_remember_period = false
131
140
 
132
141
  # Options to be passed to the created cookie. For instance, you can set
133
- # :secure => true in order to force SSL only cookies.
142
+ # secure: true in order to force SSL only cookies.
134
143
  # config.rememberable_options = {}
135
144
 
136
145
  # ==> Configuration for :validatable
137
- # Range for password length. Default is 8..128.
146
+ # Range for password length.
138
147
  config.password_length = 8..128
139
148
 
140
149
  # Email regex used to validate email formats. It simply asserts that
@@ -227,7 +236,7 @@ Devise.setup do |config|
227
236
  # ==> OmniAuth
228
237
  # Add a new OmniAuth provider. Check the wiki for more information on setting
229
238
  # up on your models and hooks.
230
- # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
239
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
231
240
 
232
241
  # ==> Warden configuration
233
242
  # If you want to use other strategies, that are not supported by Devise, or
@@ -235,7 +244,7 @@ Devise.setup do |config|
235
244
  #
236
245
  # config.warden do |manager|
237
246
  # manager.intercept_401 = false
238
- # manager.default_strategies(:scope => :user).unshift :some_external_strategy
247
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
239
248
  # end
240
249
 
241
250
  # ==> Mountable engine configurations
@@ -2,4 +2,4 @@ Welcome <%= @email %>!
2
2
 
3
3
  You can confirm your account through the link below:
4
4
 
5
- <%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %>
5
+ <%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
@@ -2,7 +2,7 @@ Hello <%= @resource.email %>!
2
2
 
3
3
  Someone has requested a link to change your password, and you can do this through the link below.
4
4
 
5
- <%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @token) %>
5
+ <%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
6
6
 
7
7
  If you didn't request this, please ignore this email.
8
8
  Your password won't change until you access the link above and create a new one.
@@ -4,4 +4,4 @@ Your account has been locked due to an excessive number of unsuccessful sign in
4
4
 
5
5
  Click the link below to unlock your account:
6
6
 
7
- <%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @token) %>
7
+ <%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
@@ -1,11 +1,11 @@
1
1
  <h2>Resend confirmation instructions</h2>
2
2
 
3
- <%= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
3
+ <%= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= f.error_notification %>
5
5
  <%= f.full_error :confirmation_token %>
6
6
 
7
7
  <div class="form-inputs">
8
- <%= f.input :email, :required => true, :autofocus => true %>
8
+ <%= f.input :email, required: true, autofocus: true %>
9
9
  </div>
10
10
 
11
11
  <div class="form-actions">
@@ -1,14 +1,14 @@
1
1
  <h2>Change your password</h2>
2
2
 
3
- <%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
3
+ <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
4
4
  <%= f.error_notification %>
5
5
 
6
- <%= f.input :reset_password_token, :as => :hidden %>
6
+ <%= f.input :reset_password_token, as: :hidden %>
7
7
  <%= f.full_error :reset_password_token %>
8
8
 
9
9
  <div class="form-inputs">
10
- <%= f.input :password, :label => "New password", :required => true, :autofocus => true %>
11
- <%= f.input :password_confirmation, :label => "Confirm your new password", :required => true %>
10
+ <%= f.input :password, label: "New password", required: true, autofocus: true %>
11
+ <%= f.input :password_confirmation, label: "Confirm your new password", required: true %>
12
12
  </div>
13
13
 
14
14
  <div class="form-actions">
@@ -1,10 +1,10 @@
1
1
  <h2>Forgot your password?</h2>
2
2
 
3
- <%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
3
+ <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= f.error_notification %>
5
5
 
6
6
  <div class="form-inputs">
7
- <%= f.input :email, :required => true, :autofocus => true %>
7
+ <%= f.input :email, required: true, autofocus: true %>
8
8
  </div>
9
9
 
10
10
  <div class="form-actions">
@@ -1,18 +1,18 @@
1
1
  <h2>Edit <%= resource_name.to_s.humanize %></h2>
2
2
 
3
- <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
3
+ <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
4
4
  <%= f.error_notification %>
5
5
 
6
6
  <div class="form-inputs">
7
- <%= f.input :email, :required => true, :autofocus => true %>
7
+ <%= f.input :email, required: true, autofocus: true %>
8
8
 
9
9
  <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
10
10
  <p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
11
11
  <% end %>
12
12
 
13
- <%= f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false %>
14
- <%= f.input :password_confirmation, :required => false %>
15
- <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %>
13
+ <%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false %>
14
+ <%= f.input :password_confirmation, required: false %>
15
+ <%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true %>
16
16
  </div>
17
17
 
18
18
  <div class="form-actions">
@@ -22,6 +22,6 @@
22
22
 
23
23
  <h3>Cancel my account</h3>
24
24
 
25
- <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>
26
26
 
27
27
  <%= link_to "Back", :back %>
@@ -1,12 +1,12 @@
1
1
  <h2>Sign up</h2>
2
2
 
3
- <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
3
+ <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
4
4
  <%= f.error_notification %>
5
5
 
6
6
  <div class="form-inputs">
7
- <%= f.input :email, :required => true, :autofocus => true %>
8
- <%= f.input :password, :required => true %>
9
- <%= f.input :password_confirmation, :required => true %>
7
+ <%= f.input :email, required: true, autofocus: true %>
8
+ <%= f.input :password, required: true %>
9
+ <%= f.input :password_confirmation, required: true %>
10
10
  </div>
11
11
 
12
12
  <div class="form-actions">
@@ -1,10 +1,10 @@
1
1
  <h2>Sign in</h2>
2
2
 
3
- <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
3
+ <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
4
  <div class="form-inputs">
5
- <%= f.input :email, :required => false, :autofocus => true %>
6
- <%= f.input :password, :required => false %>
7
- <%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
5
+ <%= f.input :email, required: false, autofocus: true %>
6
+ <%= f.input :password, required: false %>
7
+ <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
8
8
  </div>
9
9
 
10
10
  <div class="form-actions">
@@ -1,11 +1,11 @@
1
1
  <h2>Resend unlock instructions</h2>
2
2
 
3
- <%= simple_form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
3
+ <%= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= f.error_notification %>
5
5
  <%= f.full_error :unlock_token %>
6
6
 
7
7
  <div class="form-inputs">
8
- <%= f.input :email, :required => true, :autofocus => true %>
8
+ <%= f.input :email, required: true, autofocus: true %>
9
9
  </div>
10
10
 
11
11
  <div class="form-actions">
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ # Usage: cached-bundle install --deployment
3
+ #
4
+ # After running `bundle`, caches the `vendor/bundle` directory to S3.
5
+ # On the next run, restores the cached directory before running `bundle`.
6
+ # When `Gemfile.lock` changes, the cache gets rebuilt.
7
+ #
8
+ # Requirements:
9
+ # - Gemfile.lock
10
+ # - TRAVIS_REPO_SLUG
11
+ # - TRAVIS_RUBY_VERSION
12
+ # - AMAZON_S3_BUCKET
13
+ # - script/s3-put
14
+ # - bundle
15
+ # - curl
16
+ #
17
+ # Author: Mislav Marohnić
18
+
19
+ set -e
20
+
21
+ compute_md5() {
22
+ local output="$(openssl md5)"
23
+ echo "${output##* }"
24
+ }
25
+
26
+ download() {
27
+ curl --tcp-nodelay -qsfL "$1" -o "$2"
28
+ }
29
+
30
+
31
+ gemfile="${BUNDLE_GEMFILE:-Gemfile}"
32
+ bundle_fullpath="$(dirname $gemfile)/vendor/bundle"
33
+ bundle_path=${bundle_fullpath#$PWD/}
34
+ gemfile_hash="$(compute_md5 <"${gemfile}.lock")"
35
+ cache_name="${TRAVIS_RUBY_VERSION}-${gemfile_hash}.tgz"
36
+ fetch_url="http://${AMAZON_S3_BUCKET}.s3.amazonaws.com/${TRAVIS_REPO_SLUG}/${cache_name}"
37
+
38
+ if download "$fetch_url" "$cache_name"; then
39
+ echo "Reusing cached bundle ${cache_name}"
40
+ tar xzf "$cache_name"
41
+ fi
42
+
43
+ bundle "$@"
44
+
45
+ if [ ! -f "$cache_name" ] && [ -n "$AMAZON_SECRET_ACCESS_KEY" ]; then
46
+ echo "Caching \`${bundle_path}' to S3"
47
+ tar czf "$cache_name" "$bundle_path"
48
+ script/s3-put "$cache_name" "${AMAZON_S3_BUCKET}:${TRAVIS_REPO_SLUG}/${cache_name}"
49
+ fi