clearance 2.9.3 → 2.11.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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql.yml +39 -0
  3. data/.github/workflows/standardrb.yml +19 -0
  4. data/.github/workflows/tests.yml +4 -8
  5. data/Appraisals +1 -10
  6. data/CHANGELOG.md +26 -1
  7. data/CODEOWNERS +2 -0
  8. data/Gemfile +17 -14
  9. data/Gemfile.lock +139 -105
  10. data/README.md +1 -2
  11. data/Rakefile +1 -1
  12. data/app/controllers/clearance/passwords_controller.rb +6 -6
  13. data/app/mailers/clearance_mailer.rb +1 -1
  14. data/clearance.gemspec +38 -38
  15. data/config/routes.rb +7 -7
  16. data/gemfiles/rails_7.1.gemfile +3 -0
  17. data/gemfiles/rails_7.2.gemfile +3 -0
  18. data/gemfiles/rails_8.0.gemfile +5 -1
  19. data/lib/clearance/authentication.rb +4 -0
  20. data/lib/clearance/back_door.rb +3 -3
  21. data/lib/clearance/configuration.rb +6 -6
  22. data/lib/clearance/constraints.rb +2 -2
  23. data/lib/clearance/controller.rb +2 -2
  24. data/lib/clearance/default_sign_in_guard.rb +1 -1
  25. data/lib/clearance/password_strategies/bcrypt.rb +2 -2
  26. data/lib/clearance/session.rb +4 -6
  27. data/lib/clearance/sign_in_guard.rb +1 -1
  28. data/lib/clearance/testing/deny_access_matcher.rb +4 -4
  29. data/lib/clearance/token.rb +1 -1
  30. data/lib/clearance/user.rb +7 -7
  31. data/lib/clearance/version.rb +1 -1
  32. data/lib/clearance.rb +10 -10
  33. data/lib/generators/clearance/install/install_generator.rb +15 -15
  34. data/lib/generators/clearance/routes/routes_generator.rb +5 -5
  35. data/lib/generators/clearance/routes/templates/routes.rb +10 -10
  36. data/lib/generators/clearance/specs/specs_generator.rb +4 -4
  37. data/lib/generators/clearance/views/views_generator.rb +4 -4
  38. data/spec/acceptance/clearance_installation_spec.rb +3 -3
  39. data/spec/clearance/back_door_spec.rb +5 -5
  40. data/spec/clearance/constraints/signed_in_spec.rb +14 -14
  41. data/spec/clearance/constraints/signed_out_spec.rb +4 -4
  42. data/spec/clearance/default_sign_in_guard_spec.rb +6 -6
  43. data/spec/clearance/rack_session_spec.rb +9 -9
  44. data/spec/clearance/session_spec.rb +60 -62
  45. data/spec/clearance/sign_in_guard_spec.rb +7 -7
  46. data/spec/clearance/testing/controller_helpers_spec.rb +15 -14
  47. data/spec/clearance/testing/deny_access_matcher_spec.rb +1 -1
  48. data/spec/clearance/testing/view_helpers_spec.rb +2 -2
  49. data/spec/clearance/token_spec.rb +3 -3
  50. data/spec/configuration_spec.rb +8 -21
  51. data/spec/controllers/apis_controller_spec.rb +2 -2
  52. data/spec/controllers/forgeries_controller_spec.rb +12 -12
  53. data/spec/controllers/passwords_controller_spec.rb +31 -31
  54. data/spec/controllers/permissions_controller_spec.rb +13 -13
  55. data/spec/controllers/sessions_controller_spec.rb +7 -7
  56. data/spec/controllers/users_controller_spec.rb +5 -5
  57. data/spec/dummy/config/environments/test.rb +3 -3
  58. data/spec/factories/users.rb +3 -3
  59. data/spec/generators/clearance/install/install_generator_spec.rb +11 -11
  60. data/spec/generators/clearance/routes/routes_generator_spec.rb +1 -1
  61. data/spec/generators/clearance/specs/specs_generator_spec.rb +2 -2
  62. data/spec/generators/clearance/views/views_generator_spec.rb +2 -2
  63. data/spec/mailers/clearance_mailer_spec.rb +3 -2
  64. data/spec/models/user_spec.rb +2 -2
  65. data/spec/password_strategies/argon2_spec.rb +3 -3
  66. data/spec/password_strategies/bcrypt_spec.rb +4 -4
  67. data/spec/password_strategies/password_strategies_spec.rb +1 -1
  68. data/spec/requests/authentication_cookie_spec.rb +3 -3
  69. data/spec/requests/backdoor_spec.rb +1 -1
  70. data/spec/requests/cookie_options_spec.rb +2 -2
  71. data/spec/requests/csrf_rotation_spec.rb +1 -1
  72. data/spec/requests/password_maintenance_spec.rb +1 -1
  73. data/spec/requests/token_expiration_spec.rb +2 -2
  74. data/spec/routing/clearance_routes_spec.rb +36 -36
  75. data/spec/support/clearance.rb +1 -1
  76. data/spec/support/fake_model_without_password_strategy.rb +5 -2
  77. data/spec/support/generator_spec_helpers.rb +2 -2
  78. data/spec/support/request_with_remember_token.rb +1 -1
  79. metadata +5 -5
  80. data/gemfiles/rails_7.0.gemfile +0 -24
  81. data/spec/support/html_escape_helper.rb +0 -13
data/clearance.gemspec CHANGED
@@ -1,34 +1,35 @@
1
- require_relative 'lib/clearance/version'
1
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
2
+ require "clearance/version"
2
3
 
3
4
  Gem::Specification.new do |s|
4
- s.add_dependency 'bcrypt', '>= 3.1.1'
5
- s.add_dependency 'argon2', '~> 2.0', '>= 2.0.2'
6
- s.add_dependency 'email_validator', '~> 2.0'
7
- s.add_dependency 'railties', '>= 5.0'
8
- s.add_dependency 'activemodel', '>= 5.0'
9
- s.add_dependency 'activerecord', '>= 5.0'
10
- s.add_dependency 'actionmailer', '>= 5.0'
5
+ s.add_dependency "bcrypt", ">= 3.1.1"
6
+ s.add_dependency "argon2", "~> 2.0", ">= 2.0.2"
7
+ s.add_dependency "email_validator", "~> 2.0"
8
+ s.add_dependency "railties", ">= 5.0"
9
+ s.add_dependency "activemodel", ">= 5.0"
10
+ s.add_dependency "activerecord", ">= 5.0"
11
+ s.add_dependency "actionmailer", ">= 5.0"
11
12
  s.authors = [
12
- 'Dan Croak',
13
- 'Eugene Bolshakov',
14
- 'Mike Burns',
15
- 'Joe Ferris',
16
- 'Nick Quaranto',
17
- 'Josh Nichols',
18
- 'Matt Jankowski',
19
- 'Josh Clayton',
20
- 'Gabe Berke-Williams',
21
- 'Greg Lazarev',
22
- 'Mike Breen',
23
- 'Prem Sichanugrist',
24
- 'Harlow Ward',
25
- 'Ryan McGeary',
26
- 'Derek Prior',
27
- 'Jason Morrison',
28
- 'Galen Frechette',
29
- 'Josh Steiner',
30
- 'Dorian Marié',
31
- 'Sara Jackson'
13
+ "Dan Croak",
14
+ "Eugene Bolshakov",
15
+ "Mike Burns",
16
+ "Joe Ferris",
17
+ "Nick Quaranto",
18
+ "Josh Nichols",
19
+ "Matt Jankowski",
20
+ "Josh Clayton",
21
+ "Gabe Berke-Williams",
22
+ "Greg Lazarev",
23
+ "Mike Breen",
24
+ "Prem Sichanugrist",
25
+ "Harlow Ward",
26
+ "Ryan McGeary",
27
+ "Derek Prior",
28
+ "Jason Morrison",
29
+ "Galen Frechette",
30
+ "Josh Steiner",
31
+ "Dorian Marié",
32
+ "Sara Jackson"
32
33
  ]
33
34
  s.description = <<-DESCRIPTION
34
35
  Clearance is built to support authentication and authorization via an
@@ -37,16 +38,15 @@ Gem::Specification.new do |s|
37
38
  It provides some core classes commonly used for these features, along with
38
39
  some opinionated defaults - but is intended to be easy to override.
39
40
  DESCRIPTION
40
- s.email = 'support@thoughtbot.com'
41
- s.extra_rdoc_files = %w(LICENSE README.md)
41
+ s.email = "support@thoughtbot.com"
42
+ s.extra_rdoc_files = %w[LICENSE README.md]
42
43
  s.files = `git ls-files`.split("\n")
43
- s.homepage = 'https://github.com/thoughtbot/clearance'
44
- s.license = 'MIT'
45
- s.name = %q{clearance}
46
- s.rdoc_options = ['--charset=UTF-8']
47
- s.require_paths = ['lib']
48
- s.required_ruby_version = Gem::Requirement.new('>= 3.1.6')
49
- s.summary = 'Rails authentication & authorization with email & password.'
50
- s.test_files = `git ls-files -- {spec}/*`.split("\n")
44
+ s.homepage = "https://github.com/thoughtbot/clearance"
45
+ s.license = "MIT"
46
+ s.name = "clearance"
47
+ s.rdoc_options = ["--charset=UTF-8"]
48
+ s.require_paths = ["lib"]
49
+ s.required_ruby_version = Gem::Requirement.new(">= 3.1.6")
50
+ s.summary = "Rails authentication & authorization with email & password."
51
51
  s.version = Clearance::VERSION
52
52
  end
data/config/routes.rb CHANGED
@@ -1,28 +1,28 @@
1
1
  if Clearance.configuration.routes_enabled?
2
2
  Rails.application.routes.draw do
3
3
  resources :passwords,
4
- controller: 'clearance/passwords',
4
+ controller: "clearance/passwords",
5
5
  only: [:create, :new]
6
6
 
7
7
  resource :session,
8
- controller: 'clearance/sessions',
8
+ controller: "clearance/sessions",
9
9
  only: [:create]
10
10
 
11
11
  resources :users,
12
- controller: 'clearance/users',
12
+ controller: "clearance/users",
13
13
  only: Clearance.configuration.user_actions do
14
14
  if Clearance.configuration.allow_password_reset?
15
15
  resource :password,
16
- controller: 'clearance/passwords',
16
+ controller: "clearance/passwords",
17
17
  only: [:edit, :update]
18
18
  end
19
19
  end
20
20
 
21
- get '/sign_in' => 'clearance/sessions#new', as: 'sign_in'
22
- delete '/sign_out' => 'clearance/sessions#destroy', as: 'sign_out'
21
+ get "/sign_in" => "clearance/sessions#new", :as => "sign_in"
22
+ delete "/sign_out" => "clearance/sessions#destroy", :as => "sign_out"
23
23
 
24
24
  if Clearance.configuration.allow_sign_up?
25
- get '/sign_up' => 'clearance/users#new', as: 'sign_up'
25
+ get "/sign_up" => "clearance/users#new", :as => "sign_up"
26
26
  end
27
27
  end
28
28
  end
@@ -9,12 +9,15 @@ gem "capybara"
9
9
  gem "database_cleaner"
10
10
  gem "erb_lint", require: false
11
11
  gem "factory_bot_rails"
12
+ gem "ffi", "< 1.17.0"
12
13
  gem "nokogiri"
13
14
  gem "pry", require: false
14
15
  gem "rails-controller-testing"
15
16
  gem "rspec-rails"
16
17
  gem "shoulda-matchers"
17
18
  gem "sqlite3", "~> 1.7"
19
+ gem "standard", ">= 1.35.1", require: false
20
+ gem "timecop"
18
21
  gem "railties", "~> 7.1.0"
19
22
 
20
23
  gemspec path: "../"
@@ -9,12 +9,15 @@ gem "capybara"
9
9
  gem "database_cleaner"
10
10
  gem "erb_lint", require: false
11
11
  gem "factory_bot_rails"
12
+ gem "ffi", "< 1.17.0"
12
13
  gem "nokogiri"
13
14
  gem "pry", require: false
14
15
  gem "rails-controller-testing"
15
16
  gem "rspec-rails"
16
17
  gem "shoulda-matchers"
17
18
  gem "sqlite3", "~> 1.7"
19
+ gem "standard", ">= 1.35.1", require: false
20
+ gem "timecop"
18
21
  gem "railties", "~> 7.2.0"
19
22
 
20
23
  gemspec path: "../"
@@ -9,12 +9,16 @@ gem "capybara"
9
9
  gem "database_cleaner"
10
10
  gem "erb_lint", require: false
11
11
  gem "factory_bot_rails"
12
+ gem "ffi", "< 1.17.0"
12
13
  gem "nokogiri"
13
14
  gem "pry", require: false
14
15
  gem "rails-controller-testing"
15
16
  gem "rspec-rails"
16
17
  gem "shoulda-matchers"
17
- gem "sqlite3", ">= 2.1"
18
+ gem "sqlite3", "~> 2.1"
19
+ gem "standard", ">= 1.35.1", require: false
20
+ gem "timecop"
18
21
  gem "railties", "~> 8.0.0"
22
+ gem "net-smtp", require: false
19
23
 
20
24
  gemspec path: "../"
@@ -62,8 +62,12 @@ module Clearance
62
62
  #
63
63
  # Signing in will also regenerate the CSRF token for the current session,
64
64
  # provided {Configuration#rotate_csrf_on_sign_in?} is set.
65
+ # Disabling this because rubocop/standardrb wants to change `&block` to `&`,
66
+ # and that breaks Ruby 3.0.4 tests
67
+ # rubocop:disable Style/ArgumentsForwarding
65
68
  def sign_in(user, &block)
66
69
  clearance_session.sign_in(user, &block)
70
+ # rubocop:enable Style/ArgumentsForwarding
67
71
 
68
72
  if signed_in? && Clearance.configuration.rotate_csrf_on_sign_in?
69
73
  if request.respond_to?(:reset_csrf_token)
@@ -80,13 +80,13 @@ module Clearance
80
80
 
81
81
  # @api private
82
82
  def error_message
83
- unless allowed_environments.empty?
83
+ if allowed_environments.empty?
84
+ "BackDoor auth is disabled."
85
+ else
84
86
  <<-EOS.squish
85
87
  Can't use auth backdoor outside of
86
88
  configured environments (#{allowed_environments.join(", ")}).
87
89
  EOS
88
- else
89
- "BackDoor auth is disabled."
90
90
  end
91
91
  end
92
92
  end
@@ -157,11 +157,11 @@ module Clearance
157
157
  @cookie_domain = nil
158
158
  @cookie_expiration = ->(cookies) { 1.year.from_now.utc }
159
159
  @cookie_name = "remember_token"
160
- @cookie_path = '/'
160
+ @cookie_path = "/"
161
161
  @httponly = true
162
162
  @same_site = nil
163
- @mailer_sender = 'reply@example.com'
164
- @redirect_url = '/'
163
+ @mailer_sender = "reply@example.com"
164
+ @redirect_url = "/"
165
165
  @url_after_destroy = nil
166
166
  @url_after_denied_access_when_signed_out = nil
167
167
  @rotate_csrf_on_sign_in = true
@@ -208,12 +208,12 @@ module Clearance
208
208
  def allow_password_reset?
209
209
  @allow_password_reset
210
210
  end
211
-
211
+
212
212
  # Specifies which controller actions are allowed for user resources.
213
213
  # This will be `[:create]` is `allow_sign_up` is true (the default), and
214
214
  # empty otherwise.
215
215
  # @return [Array<Symbol>]
216
- def user_actions
216
+ def user_actions
217
217
  if allow_sign_up?
218
218
  [:create]
219
219
  else
@@ -234,7 +234,7 @@ module Clearance
234
234
  # In the default configuration, this is `user_id`.
235
235
  # @return [Symbol]
236
236
  def user_id_parameter
237
- "#{user_parameter}_id".to_sym
237
+ :"#{user_parameter}_id"
238
238
  end
239
239
 
240
240
  # @return [Boolean] are Clearance's built-in routes enabled?
@@ -1,5 +1,5 @@
1
- require 'clearance/constraints/signed_in'
2
- require 'clearance/constraints/signed_out'
1
+ require "clearance/constraints/signed_in"
2
+ require "clearance/constraints/signed_out"
3
3
 
4
4
  module Clearance
5
5
  # Clearance provides Rails routing constraints that can control access and the
@@ -1,5 +1,5 @@
1
- require 'clearance/authentication'
2
- require 'clearance/authorization'
1
+ require "clearance/authentication"
2
+ require "clearance/authorization"
3
3
 
4
4
  module Clearance
5
5
  # Adds clearance controller helpers to the controller it is mixed into.
@@ -29,7 +29,7 @@ module Clearance
29
29
  I18n.t(
30
30
  :bad_email_or_password,
31
31
  scope: [:clearance, :controllers, :sessions],
32
- default: I18n.t('flashes.failure_after_create').html_safe
32
+ default: I18n.t("flashes.failure_after_create").html_safe
33
33
  )
34
34
  end
35
35
  end
@@ -11,7 +11,7 @@ module Clearance
11
11
  # by setting a higher cost in an initializer:
12
12
  # `BCrypt::Engine.cost = 12`
13
13
  module BCrypt
14
- require 'bcrypt'
14
+ require "bcrypt"
15
15
 
16
16
  def authenticated?(password)
17
17
  if encrypted_password.present?
@@ -25,7 +25,7 @@ module Clearance
25
25
  if new_password.present?
26
26
  self.encrypted_password = ::BCrypt::Password.create(
27
27
  new_password,
28
- cost: configured_bcrypt_cost,
28
+ cost: configured_bcrypt_cost
29
29
  )
30
30
  end
31
31
  end
@@ -1,4 +1,4 @@
1
- require 'clearance/default_sign_in_guard'
1
+ require "clearance/default_sign_in_guard"
2
2
 
3
3
  module Clearance
4
4
  # Represents a clearance session, ultimately persisted in
@@ -57,9 +57,7 @@ module Clearance
57
57
  @current_user = nil
58
58
  end
59
59
 
60
- if block_given?
61
- block.call(status)
62
- end
60
+ block&.call(status)
63
61
  end
64
62
 
65
63
  # Invalidates the users remember token and removes the remember token cookie
@@ -89,7 +87,7 @@ module Clearance
89
87
  #
90
88
  # @return [Boolean]
91
89
  def signed_out?
92
- ! signed_in?
90
+ !signed_in?
93
91
  end
94
92
 
95
93
  # True if a successful authentication has been performed
@@ -179,7 +177,7 @@ module Clearance
179
177
  same_site: Clearance.configuration.same_site,
180
178
  path: Clearance.configuration.cookie_path,
181
179
  secure: Clearance.configuration.secure_cookie,
182
- value: value,
180
+ value: value
183
181
  }
184
182
  end
185
183
 
@@ -1,4 +1,4 @@
1
- require 'clearance/session_status'
1
+ require "clearance/session_status"
2
2
 
3
3
  module Clearance
4
4
  # The base class for {DefaultSignInGuard} and all custom sign in guards.
@@ -43,12 +43,12 @@ module Clearance
43
43
  @flash = opts[:flash]
44
44
  @url = opts[:redirect]
45
45
 
46
- @failure_message = ''
47
- @failure_message_when_negated = ''
46
+ @failure_message = ""
47
+ @failure_message_when_negated = ""
48
48
  end
49
49
 
50
50
  def description
51
- 'deny access'
51
+ "deny access"
52
52
  end
53
53
 
54
54
  def matches?(controller)
@@ -104,7 +104,7 @@ module Clearance
104
104
  "Didn't expect to set the flash to #{@flash}"
105
105
  true
106
106
  else
107
- @failure_message << "Expected the flash to be set to #{@flash} "\
107
+ @failure_message << "Expected the flash to be set to #{@flash} " \
108
108
  "but was #{flash_alert_value}"
109
109
  false
110
110
  end
@@ -8,7 +8,7 @@ module Clearance
8
8
  #
9
9
  # @return [String]
10
10
  def self.new
11
- SecureRandom.hex(20).encode('UTF-8')
11
+ SecureRandom.hex(20).encode("UTF-8")
12
12
  end
13
13
  end
14
14
  end
@@ -1,7 +1,7 @@
1
- require 'digest/sha1'
2
- require 'active_model'
3
- require 'email_validator'
4
- require 'clearance/token'
1
+ require "digest/sha1"
2
+ require "active_model"
3
+ require "email_validator"
4
+ require "clearance/token"
5
5
 
6
6
  module Clearance
7
7
  # Required to be included in your configued user class, which is `User` by
@@ -113,7 +113,7 @@ module Clearance
113
113
  # @api private
114
114
  module ClassMethods
115
115
  def authenticate(email, password)
116
- if user = find_by_normalized_email(email)
116
+ if (user = find_by_normalized_email(email))
117
117
  if password.present? && user.authenticated?(password)
118
118
  user
119
119
  end
@@ -150,9 +150,9 @@ module Clearance
150
150
 
151
151
  included do
152
152
  validates :email,
153
- email: { mode: :strict },
153
+ email: {mode: :strict},
154
154
  presence: true,
155
- uniqueness: { allow_blank: true, case_sensitive: true },
155
+ uniqueness: {allow_blank: true, case_sensitive: true},
156
156
  unless: :email_optional?
157
157
 
158
158
  validates :password, presence: true, unless: :skip_password_validation?
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = "2.9.3".freeze
2
+ VERSION = "2.11.0".freeze
3
3
  end
data/lib/clearance.rb CHANGED
@@ -1,13 +1,13 @@
1
- require 'clearance/configuration'
2
- require 'clearance/sign_in_guard'
3
- require 'clearance/session'
4
- require 'clearance/rack_session'
5
- require 'clearance/back_door'
6
- require 'clearance/controller'
7
- require 'clearance/user'
8
- require 'clearance/password_strategies'
9
- require 'clearance/constraints'
10
- require 'clearance/engine'
1
+ require "clearance/configuration"
2
+ require "clearance/sign_in_guard"
3
+ require "clearance/session"
4
+ require "clearance/rack_session"
5
+ require "clearance/back_door"
6
+ require "clearance/controller"
7
+ require "clearance/user"
8
+ require "clearance/password_strategies"
9
+ require "clearance/constraints"
10
+ require "clearance/engine"
11
11
 
12
12
  module Clearance
13
13
  end
@@ -1,14 +1,14 @@
1
- require 'rails/generators/base'
2
- require 'rails/generators/active_record'
1
+ require "rails/generators/base"
2
+ require "rails/generators/active_record"
3
3
 
4
4
  module Clearance
5
5
  module Generators
6
6
  class InstallGenerator < Rails::Generators::Base
7
7
  include Rails::Generators::Migration
8
- source_root File.expand_path('../templates', __FILE__)
8
+ source_root File.expand_path("../templates", __FILE__)
9
9
 
10
10
  def create_clearance_initializer
11
- copy_file 'clearance.rb', 'config/initializers/clearance.rb'
11
+ copy_file "clearance.rb", "config/initializers/clearance.rb"
12
12
  end
13
13
 
14
14
  def inject_clearance_into_application_controller
@@ -24,7 +24,7 @@ module Clearance
24
24
  inject_into_file(
25
25
  "app/models/user.rb",
26
26
  " include Clearance::User\n\n",
27
- after: "class User < #{models_inherit_from}\n",
27
+ after: "class User < #{models_inherit_from}\n"
28
28
  )
29
29
  else
30
30
  @inherit_from = models_inherit_from
@@ -41,7 +41,12 @@ module Clearance
41
41
  end
42
42
 
43
43
  def display_readme_in_terminal
44
- readme 'README'
44
+ readme "README"
45
+ end
46
+
47
+ # for generating a timestamp when using `create_migration`
48
+ def self.next_migration_number(dir)
49
+ ActiveRecord::Generators::Base.next_migration_number(dir)
45
50
  end
46
51
 
47
52
  private
@@ -62,7 +67,7 @@ module Clearance
62
67
  migration_template(
63
68
  "db/migrate/#{migration_name}.rb.erb",
64
69
  "db/migrate/#{migration_name}.rb",
65
- config.merge(migration_version: migration_version),
70
+ config.merge(migration_version: migration_version)
66
71
  )
67
72
  end
68
73
  end
@@ -76,7 +81,7 @@ module Clearance
76
81
  email: "t.string :email",
77
82
  encrypted_password: "t.string :encrypted_password, limit: 128",
78
83
  confirmation_token: "t.string :confirmation_token, limit: 128",
79
- remember_token: "t.string :remember_token, limit: 128",
84
+ remember_token: "t.string :remember_token, limit: 128"
80
85
  }.reject { |column| existing_users_columns.include?(column.to_s) }
81
86
  end
82
87
 
@@ -87,7 +92,7 @@ module Clearance
87
92
  index_users_on_confirmation_token:
88
93
  "add_index :users, :confirmation_token, unique: true",
89
94
  index_users_on_remember_token:
90
- "add_index :users, :remember_token, unique: true",
95
+ "add_index :users, :remember_token, unique: true"
91
96
  }.reject { |index| existing_users_indexes.include?(index.to_s) }
92
97
  end
93
98
 
@@ -102,7 +107,7 @@ module Clearance
102
107
  end
103
108
 
104
109
  def migration_name_without_timestamp(file)
105
- file.sub(%r{^.*(db/migrate/)(?:\d+_)?}, '')
110
+ file.sub(%r{^.*(db/migrate/)(?:\d+_)?}, "")
106
111
  end
107
112
 
108
113
  def users_table_exists?
@@ -117,11 +122,6 @@ module Clearance
117
122
  ActiveRecord::Base.connection.indexes(:users).map(&:name)
118
123
  end
119
124
 
120
- # for generating a timestamp when using `create_migration`
121
- def self.next_migration_number(dir)
122
- ActiveRecord::Generators::Base.next_migration_number(dir)
123
- end
124
-
125
125
  def migration_version
126
126
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
127
127
  end
@@ -1,9 +1,9 @@
1
- require 'rails/generators/base'
1
+ require "rails/generators/base"
2
2
 
3
3
  module Clearance
4
4
  module Generators
5
5
  class RoutesGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../templates', __FILE__)
6
+ source_root File.expand_path("../templates", __FILE__)
7
7
 
8
8
  def inject_clearance_routes_into_application_routes
9
9
  route(clearance_routes)
@@ -13,7 +13,7 @@ module Clearance
13
13
  inject_into_file(
14
14
  "config/initializers/clearance.rb",
15
15
  " config.routes = false\n",
16
- after: "Clearance.configure do |config|\n",
16
+ after: "Clearance.configure do |config|\n"
17
17
  )
18
18
  end
19
19
 
@@ -24,7 +24,7 @@ module Clearance
24
24
  end
25
25
 
26
26
  def routes_file_path
27
- File.expand_path(find_in_source_paths('routes.rb'))
27
+ File.expand_path(find_in_source_paths("routes.rb"))
28
28
  end
29
29
 
30
30
  def route(routing_code)
@@ -37,7 +37,7 @@ module Clearance
37
37
  routing_code,
38
38
  after: sentinel,
39
39
  verbose: false,
40
- force: true,
40
+ force: true
41
41
  )
42
42
  end
43
43
  end
@@ -1,12 +1,12 @@
1
- resources :passwords, controller: "clearance/passwords", only: [:create, :new]
2
- resource :session, controller: "clearance/sessions", only: [:create]
1
+ resources :passwords, controller: "clearance/passwords", only: [:create, :new]
2
+ resource :session, controller: "clearance/sessions", only: [:create]
3
3
 
4
- resources :users, controller: "clearance/users", only: [:create] do
5
- resource :password,
6
- controller: "clearance/passwords",
7
- only: [:edit, :update]
8
- end
4
+ resources :users, controller: "clearance/users", only: [:create] do
5
+ resource :password,
6
+ controller: "clearance/passwords",
7
+ only: [:edit, :update]
8
+ end
9
9
 
10
- get "/sign_in" => "clearance/sessions#new", as: "sign_in"
11
- delete "/sign_out" => "clearance/sessions#destroy", as: "sign_out"
12
- get "/sign_up" => "clearance/users#new", as: "sign_up"
10
+ get "/sign_in" => "clearance/sessions#new", :as => "sign_in"
11
+ delete "/sign_out" => "clearance/sessions#destroy", :as => "sign_out"
12
+ get "/sign_up" => "clearance/users#new", :as => "sign_up"
@@ -1,14 +1,14 @@
1
- require 'rails/generators/base'
2
- require 'rspec/rails/version'
1
+ require "rails/generators/base"
2
+ require "rspec/rails/version"
3
3
 
4
4
  module Clearance
5
5
  module Generators
6
6
  class SpecsGenerator < Rails::Generators::Base
7
- source_root File.expand_path('../templates', __FILE__)
7
+ source_root File.expand_path("../templates", __FILE__)
8
8
 
9
9
  def create_specs
10
10
  @helper_file = rspec_helper_file
11
- directory '.', 'spec'
11
+ directory ".", "spec"
12
12
  end
13
13
 
14
14
  private
@@ -1,4 +1,4 @@
1
- require 'rails/generators/base'
1
+ require "rails/generators/base"
2
2
 
3
3
  module Clearance
4
4
  module Generators
@@ -20,18 +20,18 @@ module Clearance
20
20
  private
21
21
 
22
22
  def views
23
- files_within_root('.', 'app/views/**/*.*')
23
+ files_within_root(".", "app/views/**/*.*")
24
24
  end
25
25
 
26
26
  def locales
27
- files_within_root('.', 'config/locales/**/*.*')
27
+ files_within_root(".", "config/locales/**/*.*")
28
28
  end
29
29
 
30
30
  def files_within_root(prefix, glob)
31
31
  root = "#{self.class.source_root}/#{prefix}"
32
32
 
33
33
  Dir["#{root}/#{glob}"].sort.map do |full_path|
34
- full_path.sub(root, '.').gsub('/./', '/')
34
+ full_path.sub(root, ".").gsub("/./", "/")
35
35
  end
36
36
  end
37
37
  end