devise-otp 0.3.0 → 0.5.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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/CHANGELOG.md +17 -0
  4. data/Gemfile +0 -0
  5. data/LICENSE.txt +0 -0
  6. data/README.md +1 -1
  7. data/Rakefile +17 -18
  8. data/app/assets/javascripts/devise-otp.js +0 -0
  9. data/app/assets/javascripts/qrcode.js +0 -0
  10. data/app/controllers/devise_otp/devise/{credentials_controller.rb → otp_credentials_controller.rb} +17 -21
  11. data/app/controllers/devise_otp/devise/{tokens_controller.rb → otp_tokens_controller.rb} +9 -13
  12. data/app/views/devise/{credentials → otp_credentials}/refresh.html.erb +0 -0
  13. data/app/views/devise/{credentials → otp_credentials}/show.html.erb +1 -1
  14. data/app/views/devise/{tokens → otp_tokens}/_token_secret.html.erb +4 -4
  15. data/app/views/devise/{tokens → otp_tokens}/_trusted_devices.html.erb +0 -0
  16. data/app/views/devise/{tokens → otp_tokens}/recovery.html.erb +4 -4
  17. data/app/views/devise/{tokens → otp_tokens}/recovery_codes.text.erb +0 -0
  18. data/app/views/devise/{tokens → otp_tokens}/show.html.erb +5 -5
  19. data/config/locales/en.yml +4 -12
  20. data/devise-otp.gemspec +13 -13
  21. data/lib/devise-otp/version.rb +2 -2
  22. data/lib/devise-otp.rb +15 -29
  23. data/lib/devise_otp_authenticatable/controllers/helpers.rb +21 -23
  24. data/lib/devise_otp_authenticatable/controllers/url_helpers.rb +0 -2
  25. data/lib/devise_otp_authenticatable/engine.rb +6 -4
  26. data/lib/devise_otp_authenticatable/hooks/sessions.rb +4 -5
  27. data/lib/devise_otp_authenticatable/hooks.rb +1 -3
  28. data/lib/devise_otp_authenticatable/models/otp_authenticatable.rb +19 -25
  29. data/lib/devise_otp_authenticatable/routes.rb +11 -14
  30. data/lib/generators/active_record/devise_otp_generator.rb +1 -1
  31. data/lib/generators/active_record/templates/migration.rb +0 -0
  32. data/lib/generators/devise_otp/devise_otp_generator.rb +12 -13
  33. data/lib/generators/devise_otp/install_generator.rb +3 -4
  34. data/lib/generators/devise_otp/views_generator.rb +5 -5
  35. data/test/dummy/README.rdoc +0 -0
  36. data/test/dummy/Rakefile +1 -1
  37. data/test/dummy/app/assets/config/manifest.js +0 -0
  38. data/test/dummy/app/assets/javascripts/application.js +0 -0
  39. data/test/dummy/app/assets/stylesheets/application.css +0 -0
  40. data/test/dummy/app/controllers/application_controller.rb +0 -0
  41. data/test/dummy/app/controllers/posts_controller.rb +2 -2
  42. data/test/dummy/app/helpers/application_helper.rb +0 -0
  43. data/test/dummy/app/helpers/posts_helper.rb +0 -0
  44. data/test/dummy/app/mailers/.gitkeep +0 -0
  45. data/test/dummy/app/models/post.rb +0 -0
  46. data/test/dummy/app/models/user.rb +8 -8
  47. data/test/dummy/app/views/layouts/application.html.erb +0 -0
  48. data/test/dummy/app/views/posts/_form.html.erb +0 -0
  49. data/test/dummy/app/views/posts/edit.html.erb +0 -0
  50. data/test/dummy/app/views/posts/index.html.erb +0 -0
  51. data/test/dummy/app/views/posts/new.html.erb +0 -0
  52. data/test/dummy/app/views/posts/show.html.erb +0 -0
  53. data/test/dummy/config/application.rb +4 -4
  54. data/test/dummy/config/boot.rb +5 -5
  55. data/test/dummy/config/database.yml +0 -0
  56. data/test/dummy/config/environment.rb +1 -1
  57. data/test/dummy/config/environments/development.rb +1 -1
  58. data/test/dummy/config/environments/production.rb +1 -1
  59. data/test/dummy/config/environments/test.rb +2 -2
  60. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -0
  61. data/test/dummy/config/initializers/devise.rb +6 -8
  62. data/test/dummy/config/initializers/inflections.rb +0 -0
  63. data/test/dummy/config/initializers/mime_types.rb +0 -0
  64. data/test/dummy/config/initializers/secret_token.rb +2 -2
  65. data/test/dummy/config/initializers/session_store.rb +1 -1
  66. data/test/dummy/config/initializers/wrap_parameters.rb +1 -1
  67. data/test/dummy/config/locales/en.yml +0 -0
  68. data/test/dummy/config/routes.rb +1 -1
  69. data/test/dummy/config.ru +1 -1
  70. data/test/dummy/db/migrate/20130125101430_create_users.rb +0 -0
  71. data/test/dummy/db/migrate/20130131092406_add_devise_to_users.rb +12 -13
  72. data/test/dummy/db/migrate/20130131142320_create_posts.rb +0 -0
  73. data/test/dummy/db/migrate/20130131160351_devise_otp_add_to_users.rb +13 -13
  74. data/test/dummy/lib/assets/.gitkeep +0 -0
  75. data/test/dummy/public/404.html +0 -0
  76. data/test/dummy/public/422.html +0 -0
  77. data/test/dummy/public/500.html +0 -0
  78. data/test/dummy/public/favicon.ico +0 -0
  79. data/test/dummy/script/rails +3 -3
  80. data/test/integration/persistence_test.rb +11 -12
  81. data/test/integration/refresh_test.rb +13 -14
  82. data/test/integration/sign_in_test.rb +24 -26
  83. data/test/integration/token_test.rb +5 -6
  84. data/test/integration_tests_helper.rb +16 -17
  85. data/test/model_tests_helper.rb +5 -7
  86. data/test/models/otp_authenticatable_test.rb +18 -19
  87. data/test/orm/active_record.rb +0 -0
  88. data/test/test_helper.rb +10 -10
  89. metadata +32 -73
  90. data/test/dummy/db/test.sqlite3-journal +0 -0
@@ -1,7 +1,6 @@
1
1
  module DeviseOtpAuthenticatable
2
2
  module Controllers
3
3
  module UrlHelpers
4
-
5
4
  def recovery_otp_token_for(resource_or_scope, opts = {})
6
5
  scope = ::Devise::Mapping.find_scope!(resource_or_scope)
7
6
  send("recovery_#{scope}_otp_token_path", opts)
@@ -26,7 +25,6 @@ module DeviseOtpAuthenticatable
26
25
  scope = ::Devise::Mapping.find_scope!(resource_or_scope)
27
26
  send("#{scope}_otp_credential_path", opts)
28
27
  end
29
-
30
28
  end
31
29
  end
32
30
  end
@@ -1,5 +1,7 @@
1
1
  module DeviseOtpAuthenticatable
2
2
  class Engine < ::Rails::Engine
3
+ config.devise_otp = ActiveSupport::OrderedOptions.new
4
+ config.devise_otp.precompile_assets = true
3
5
 
4
6
  # We use to_prepare instead of after_initialize here because Devise is a Rails engine;
5
7
  config.to_prepare do
@@ -19,12 +21,12 @@ module DeviseOtpAuthenticatable
19
21
 
20
22
  # See: https://guides.rubyonrails.org/engines.html#separate-assets-and-precompiling
21
23
  # check if Rails api mode
22
- if app.config.respond_to?(:assets)
23
- if defined?(Sprockets) && Sprockets::VERSION >= "4"
24
- app.config.assets.precompile << "devise-otp.js"
24
+ if app.config.respond_to?(:assets) && app.config.devise_otp.precompile_assets
25
+ app.config.assets.precompile << if defined?(Sprockets) && Sprockets::VERSION >= "4"
26
+ "devise-otp.js"
25
27
  else
26
28
  # use a proc instead of a string
27
- app.config.assets.precompile << proc { |path| path == "devise-otp.js" }
29
+ proc { |path| path == "devise-otp.js" }
28
30
  end
29
31
  end
30
32
  end
@@ -4,7 +4,7 @@ module DeviseOtpAuthenticatable::Hooks
4
4
  include DeviseOtpAuthenticatable::Controllers::UrlHelpers
5
5
 
6
6
  included do
7
- alias_method :create, :create_with_otp
7
+ alias_method :create, :create_with_otp
8
8
  end
9
9
 
10
10
  #
@@ -22,15 +22,14 @@ module DeviseOtpAuthenticatable::Hooks
22
22
  challenge = resource.generate_otp_challenge!
23
23
  warden.logout
24
24
  store_location_for(resource, devise_stored_location) # restore the stored location
25
- respond_with resource, :location => otp_credential_path_for(resource, {:challenge => challenge})
25
+ respond_with resource, location: otp_credential_path_for(resource, {challenge: challenge})
26
26
  elsif otp_mandatory_on?(resource) # if mandatory, log in user but send him to the must activate otp
27
27
  set_flash_message(:notice, :signed_in_but_otp) if is_navigational_format?
28
28
  sign_in(resource_name, resource)
29
- respond_with resource, :location => otp_token_path_for(resource)
29
+ respond_with resource, location: otp_token_path_for(resource)
30
30
  else
31
- set_flash_message(:notice, :signed_in) if is_navigational_format?
32
31
  sign_in(resource_name, resource)
33
- respond_with resource, :location => after_sign_in_path_for(resource)
32
+ respond_with resource, location: after_sign_in_path_for(resource)
34
33
  end
35
34
  end
36
35
 
@@ -1,13 +1,11 @@
1
1
  module DeviseOtpAuthenticatable
2
2
  module Hooks
3
-
4
- autoload :Sessions, 'devise_otp_authenticatable/hooks/sessions.rb'
3
+ autoload :Sessions, "devise_otp_authenticatable/hooks/sessions.rb"
5
4
 
6
5
  class << self
7
6
  def apply
8
7
  ::Devise::SessionsController.send(:include, Hooks::Sessions)
9
8
  end
10
9
  end
11
-
12
10
  end
13
11
  end
@@ -1,27 +1,27 @@
1
- require 'rotp'
1
+ require "rotp"
2
2
 
3
3
  module Devise::Models
4
4
  module OtpAuthenticatable
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- before_validation :generate_otp_auth_secret, :on => :create
9
- before_validation :generate_otp_persistence_seed, :on => :create
10
- scope :with_valid_otp_challenge, lambda { |time| where('otp_challenge_expires > ?', time) }
8
+ before_validation :generate_otp_auth_secret, on: :create
9
+ before_validation :generate_otp_persistence_seed, on: :create
10
+ scope :with_valid_otp_challenge, lambda { |time| where("otp_challenge_expires > ?", time) }
11
11
  end
12
12
 
13
13
  module ClassMethods
14
14
  ::Devise::Models.config(self, :otp_authentication_timeout, :otp_drift_window, :otp_trust_persistence,
15
- :otp_mandatory, :otp_credentials_refresh, :otp_issuer, :otp_recovery_tokens,
16
- :otp_controller_path)
15
+ :otp_mandatory, :otp_credentials_refresh, :otp_issuer, :otp_recovery_tokens,
16
+ :otp_controller_path)
17
17
 
18
18
  def find_valid_otp_challenge(challenge)
19
- with_valid_otp_challenge(Time.now).where(:otp_session_challenge => challenge).first
19
+ with_valid_otp_challenge(Time.now).where(otp_session_challenge: challenge).first
20
20
  end
21
21
  end
22
22
 
23
23
  def time_based_otp
24
- @time_based_otp ||= ROTP::TOTP.new(otp_auth_secret, issuer: "#{self.class.otp_issuer || Rails.application.class.module_parent_name}")
24
+ @time_based_otp ||= ROTP::TOTP.new(otp_auth_secret, issuer: (self.class.otp_issuer || Rails.application.class.module_parent_name).to_s)
25
25
  end
26
26
 
27
27
  def recovery_otp
@@ -36,15 +36,14 @@ module Devise::Models
36
36
  email
37
37
  end
38
38
 
39
-
40
39
  def reset_otp_credentials
41
40
  @time_based_otp = nil
42
41
  @recovery_otp = nil
43
42
  generate_otp_auth_secret
44
43
  reset_otp_persistence
45
- update!(:otp_enabled => false,
46
- :otp_session_challenge => nil, :otp_challenge_expires => nil,
47
- :otp_recovery_counter => 0)
44
+ update!(otp_enabled: false,
45
+ otp_session_challenge: nil, otp_challenge_expires: nil,
46
+ otp_recovery_counter: 0)
48
47
  end
49
48
 
50
49
  def reset_otp_credentials!
@@ -66,16 +65,16 @@ module Devise::Models
66
65
  reset_otp_credentials!
67
66
  end
68
67
 
69
- update!(:otp_enabled => true, :otp_enabled_on => Time.now)
68
+ update!(otp_enabled: true, otp_enabled_on: Time.now)
70
69
  end
71
70
 
72
71
  def disable_otp!
73
- update!(:otp_enabled => false, :otp_enabled_on => nil)
72
+ update!(otp_enabled: false, otp_enabled_on: nil)
74
73
  end
75
74
 
76
75
  def generate_otp_challenge!(expires = nil)
77
- update!(:otp_session_challenge => SecureRandom.hex,
78
- :otp_challenge_expires => DateTime.now + (expires || self.class.otp_authentication_timeout))
76
+ update!(otp_session_challenge: SecureRandom.hex,
77
+ otp_challenge_expires: DateTime.now + (expires || self.class.otp_authentication_timeout))
79
78
  otp_session_challenge
80
79
  end
81
80
 
@@ -83,7 +82,6 @@ module Devise::Models
83
82
  (otp_challenge_expires.nil? || otp_challenge_expires > Time.now)
84
83
  end
85
84
 
86
-
87
85
  def validate_otp_token(token, recovery = false)
88
86
  if recovery
89
87
  validate_otp_recovery_token token
@@ -100,9 +98,8 @@ module Devise::Models
100
98
  alias_method :valid_otp_time_token?, :validate_otp_time_token
101
99
 
102
100
  def next_otp_recovery_tokens(number = self.class.otp_recovery_tokens)
103
- (otp_recovery_counter..otp_recovery_counter + number).inject({}) do |h, index|
101
+ (otp_recovery_counter..otp_recovery_counter + number).each_with_object({}) do |index, h|
104
102
  h[index] = recovery_otp.at(index)
105
- h
106
103
  end
107
104
  end
108
105
 
@@ -114,15 +111,13 @@ module Devise::Models
114
111
  end
115
112
  alias_method :valid_otp_recovery_token?, :validate_otp_recovery_token
116
113
 
117
-
118
-
119
114
  private
120
115
 
121
116
  def validate_otp_token_with_drift(token)
122
-
123
117
  # should be centered around saved drift
124
- (-self.class.otp_drift_window..self.class.otp_drift_window).any? {|drift|
125
- (time_based_otp.verify(token, at: Time.now.ago(30 * drift))) }
118
+ (-self.class.otp_drift_window..self.class.otp_drift_window).any? { |drift|
119
+ time_based_otp.verify(token, at: Time.now.ago(30 * drift))
120
+ }
126
121
  end
127
122
 
128
123
  def generate_otp_persistence_seed
@@ -133,6 +128,5 @@ module Devise::Models
133
128
  self.otp_auth_secret = ROTP::Base32.random_base32
134
129
  self.otp_recovery_secret = ROTP::Base32.random_base32
135
130
  end
136
-
137
131
  end
138
132
  end
@@ -1,27 +1,24 @@
1
1
  module ActionDispatch::Routing
2
2
  class Mapper
3
-
4
3
  protected
5
4
 
6
5
  def devise_otp(mapping, controllers)
7
- namespace :otp, :module => :devise_otp do
8
- resource :token, :only => [:show, :update, :destroy],
9
- :path => mapping.path_names[:token], :controller => controllers[:tokens] do
10
-
6
+ namespace :otp, module: :devise_otp do
7
+ resource :token, only: [:show, :update, :destroy],
8
+ path: mapping.path_names[:token], controller: controllers[:otp_tokens] do
11
9
  if Devise.otp_trust_persistence
12
- get :persistence, :action => 'get_persistence'
13
- post :persistence, :action => 'clear_persistence'
14
- delete :persistence, :action => 'delete_persistence'
10
+ get :persistence, action: "get_persistence"
11
+ post :persistence, action: "clear_persistence"
12
+ delete :persistence, action: "delete_persistence"
15
13
  end
16
14
 
17
- get :recovery
15
+ get :recovery
18
16
  end
19
17
 
20
- resource :credential, :only => [:show, :update],
21
- :path => mapping.path_names[:credentials], :controller => controllers[:credentials] do
22
-
23
- get :refresh, :action => 'get_refresh'
24
- put :refresh, :action => 'set_refresh'
18
+ resource :credential, only: [:show, :update],
19
+ path: mapping.path_names[:credentials], controller: controllers[:otp_credentials] do
20
+ get :refresh, action: "get_refresh"
21
+ put :refresh, action: "set_refresh"
25
22
  end
26
23
  end
27
24
  end
@@ -1,4 +1,4 @@
1
- require 'rails/generators/active_record'
1
+ require "rails/generators/active_record"
2
2
 
3
3
  module ActiveRecord
4
4
  module Generators
File without changes
@@ -1,17 +1,16 @@
1
1
  module DeviseOtp
2
- module Generators
3
- class DeviseOtpGenerator < Rails::Generators::NamedBase
2
+ module Generators
3
+ class DeviseOtpGenerator < Rails::Generators::NamedBase
4
+ namespace "devise_otp"
4
5
 
5
- namespace "devise_otp"
6
+ desc "Add :otp_authenticatable directive in the given model, plus accessors. Also generate migration for ActiveRecord"
6
7
 
7
- desc "Add :otp_authenticatable directive in the given model, plus accessors. Also generate migration for ActiveRecord"
8
+ def inject_devise_otp_content
9
+ path = File.join("app", "models", "#{file_path}.rb")
10
+ inject_into_file(path, "otp_authenticatable, :", after: "devise :") if File.exist?(path)
11
+ end
8
12
 
9
- def inject_devise_otp_content
10
- path = File.join("app","models","#{file_path}.rb")
11
- inject_into_file(path, "otp_authenticatable, :", :after => "devise :") if File.exists?(path)
12
- end
13
-
14
- hook_for :orm
15
- end
16
- end
17
- end
13
+ hook_for :orm
14
+ end
15
+ end
16
+ end
@@ -7,8 +7,7 @@ module DeviseOtp
7
7
  desc "Install the devise OTP authentication extension"
8
8
 
9
9
  def add_configs
10
-
11
- content = <<-CONTENT
10
+ content = <<-CONTENT
12
11
 
13
12
  # ==> Devise OTP Extension
14
13
  # Configure OTP extension for devise
@@ -43,9 +42,9 @@ content = <<-CONTENT
43
42
  # Custom view path for Devise OTP controllers
44
43
  #config.otp_controller_path = 'devise'
45
44
 
46
- CONTENT
45
+ CONTENT
47
46
 
48
- inject_into_file "config/initializers/devise.rb", content, :before => /end[ |\n|]+\Z/
47
+ inject_into_file "config/initializers/devise.rb", content, before: /end[ |\n]+\Z/
49
48
  end
50
49
 
51
50
  def copy_locale
@@ -1,17 +1,17 @@
1
- require 'generators/devise/views_generator'
1
+ require "generators/devise/views_generator"
2
2
 
3
3
  module DeviseOtp
4
4
  module Generators
5
5
  class ViewsGenerator < Rails::Generators::Base
6
- desc 'Copies all Devise OTP views to your application.'
6
+ desc "Copies all Devise OTP views to your application."
7
7
 
8
- argument :scope, :required => false, :default => nil,
9
- :desc => "The scope to copy views to"
8
+ argument :scope, required: false, default: nil,
9
+ desc: "The scope to copy views to"
10
10
 
11
11
  include ::Devise::Generators::ViewPathTemplates
12
12
  source_root File.expand_path("../../../../app/views", __FILE__)
13
13
  def copy_views
14
- view_directory :devise, 'app/views/devise'
14
+ view_directory :devise, "app/views/devise"
15
15
  end
16
16
  end
17
17
  end
File without changes
data/test/dummy/Rakefile CHANGED
@@ -2,6 +2,6 @@
2
2
  # Add your own tasks in files placed in lib/tasks ending in .rake,
3
3
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
4
 
5
- require File.expand_path('../config/application', __FILE__)
5
+ require File.expand_path("../config/application", __FILE__)
6
6
 
7
7
  Dummy::Application.load_tasks
File without changes
File without changes
File without changes
File without changes
@@ -46,7 +46,7 @@ class PostsController < ApplicationController
46
46
 
47
47
  respond_to do |format|
48
48
  if @post.save
49
- format.html { redirect_to @post, notice: 'Post was successfully created.' }
49
+ format.html { redirect_to @post, notice: "Post was successfully created." }
50
50
  format.json { render json: @post, status: :created, location: @post }
51
51
  else
52
52
  format.html { render action: "new" }
@@ -62,7 +62,7 @@ class PostsController < ApplicationController
62
62
 
63
63
  respond_to do |format|
64
64
  if @post.update_attributes(params[:post])
65
- format.html { redirect_to @post, notice: 'Post was successfully updated.' }
65
+ format.html { redirect_to @post, notice: "Post was successfully updated." }
66
66
  format.json { head :ok }
67
67
  else
68
68
  format.html { render action: "edit" }
File without changes
File without changes
File without changes
File without changes
@@ -3,18 +3,18 @@ class User < PARENT_MODEL_CLASS
3
3
  include Mongoid::Document
4
4
 
5
5
  ## Database authenticatable
6
- field :email, :type => String, :null => false, :default => ""
7
- field :encrypted_password, :type => String, :null => false, :default => ""
6
+ field :email, type: String, null: false, default: ""
7
+ field :encrypted_password, type: String, null: false, default: ""
8
8
 
9
9
  ## Recoverable
10
- field :reset_password_token, :type => String
11
- field :reset_password_sent_at, :type => Time
10
+ field :reset_password_token, type: String
11
+ field :reset_password_sent_at, type: Time
12
12
  end
13
13
 
14
14
  devise :otp_authenticatable, :database_authenticatable, :registerable,
15
- :trackable, :validatable
15
+ :trackable, :validatable
16
16
 
17
17
  # Setup accessible (or protected) attributes for your model
18
- #attr_accessible :otp_enabled, :otp_mandatory, :as => :otp_privileged
19
- #attr_accessible :email, :password, :password_confirmation, :remember_me
20
- end
18
+ # attr_accessible :otp_enabled, :otp_mandatory, :as => :otp_privileged
19
+ # attr_accessible :email, :password, :password_confirmation, :remember_me
20
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,10 +1,10 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require File.expand_path("../boot", __FILE__)
2
2
 
3
3
  # Pick the frameworks you want:
4
4
  require "active_record/railtie"
5
5
  require "action_controller/railtie"
6
6
  require "action_mailer/railtie"
7
- #require "active_resource/railtie"
7
+ # require "active_resource/railtie"
8
8
  require "sprockets/railtie"
9
9
  # require "rails/test_unit/railtie"
10
10
 
@@ -15,7 +15,7 @@ begin
15
15
  require "#{DEVISE_ORM}/railtie"
16
16
  rescue LoadError
17
17
  end
18
- PARENT_MODEL_CLASS = DEVISE_ORM == :active_record ? ActiveRecord::Base : Object
18
+ PARENT_MODEL_CLASS = (DEVISE_ORM == :active_record) ? ActiveRecord::Base : Object
19
19
 
20
20
  require "devise"
21
21
  require "devise-otp"
@@ -64,6 +64,6 @@ module Dummy
64
64
  config.assets.enabled = true
65
65
 
66
66
  # Version of your assets, change this if you want to expire all your assets
67
- config.assets.version = '1.0'
67
+ config.assets.version = "1.0"
68
68
  end
69
69
  end
@@ -1,10 +1,10 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
1
+ require "rubygems"
2
+ gemfile = File.expand_path("../../../../Gemfile", __FILE__)
3
3
 
4
4
  if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
5
+ ENV["BUNDLE_GEMFILE"] = gemfile
6
+ require "bundler"
7
7
  Bundler.setup
8
8
  end
9
9
 
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
10
+ $:.unshift File.expand_path("../../../../lib", __FILE__)
File without changes
@@ -1,5 +1,5 @@
1
1
  # Load the rails application
2
- require File.expand_path('../application', __FILE__)
2
+ require File.expand_path("../application", __FILE__)
3
3
 
4
4
  # Initialize the rails application
5
5
  Dummy::Application.initialize!
@@ -10,7 +10,7 @@ Dummy::Application.configure do
10
10
  config.eager_load = false
11
11
 
12
12
  # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
13
+ config.consider_all_requests_local = true
14
14
  config.action_controller.perform_caching = false
15
15
 
16
16
  # Don't care if the mailer can't send
@@ -11,7 +11,7 @@ Dummy::Application.configure do
11
11
  config.eager_load = true
12
12
 
13
13
  # Full error reports are disabled and caching is turned on
14
- config.consider_all_requests_local = false
14
+ config.consider_all_requests_local = false
15
15
  config.action_controller.perform_caching = true
16
16
 
17
17
  # Disable Rails's static asset server (Apache or nginx will already do this)
@@ -17,14 +17,14 @@ Dummy::Application.configure do
17
17
  config.static_cache_control = "public, max-age=3600"
18
18
 
19
19
  # Show full error reports and disable caching
20
- config.consider_all_requests_local = true
20
+ config.consider_all_requests_local = true
21
21
  config.action_controller.perform_caching = false
22
22
 
23
23
  # Raise exceptions instead of rendering exception templates
24
24
  config.action_dispatch.show_exceptions = false
25
25
 
26
26
  # Disable request forgery protection in test environment
27
- config.action_controller.allow_forgery_protection = false
27
+ config.action_controller.allow_forgery_protection = false
28
28
 
29
29
  # Tell Action Mailer not to deliver emails to the real world.
30
30
  # The :test delivery method accumulates sent emails in the
@@ -1,8 +1,7 @@
1
1
  # Use this hook to configure devise mailer, warden hooks and so forth.
2
2
  # Many of these configuration options can be set straight in your model.
3
3
  Devise.setup do |config|
4
-
5
- config.secret_key = '638da6a325f1de9038321504c4a06ef7f4f7f835331a63ba41b93732b3830d032b6a10b38afa67427e050b19f9717b1e7a45f650ac5631c53cc9dd85264fdfb0'
4
+ config.secret_key = "638da6a325f1de9038321504c4a06ef7f4f7f835331a63ba41b93732b3830d032b6a10b38afa67427e050b19f9717b1e7a45f650ac5631c53cc9dd85264fdfb0"
6
5
 
7
6
  # ==> Mailer Configuration
8
7
  # Configure the e-mail address which will be shown in Devise::Mailer,
@@ -16,7 +15,7 @@ Devise.setup do |config|
16
15
  # Load and configure the ORM. Supports :active_record (default) and
17
16
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
18
17
  # available as additional gems.
19
- require 'devise/orm/active_record'
18
+ require "devise/orm/active_record"
20
19
 
21
20
  # ==> Configuration for any authentication mechanism
22
21
  # Configure which keys are used when authenticating a user. The default is
@@ -38,12 +37,12 @@ Devise.setup do |config|
38
37
  # Configure which authentication keys should be case-insensitive.
39
38
  # These keys will be downcased upon creating or modifying a user and when used
40
39
  # to authenticate or find a user. Default is :email.
41
- config.case_insensitive_keys = [ :email ]
40
+ config.case_insensitive_keys = [:email]
42
41
 
43
42
  # Configure which authentication keys should have whitespace stripped.
44
43
  # These keys will have whitespace before and after removed upon creating or
45
44
  # modifying a user and when used to authenticate or find a user. Default is :email.
46
- config.strip_whitespace_keys = [ :email ]
45
+ config.strip_whitespace_keys = [:email]
47
46
 
48
47
  # Tell if authentication through request.params is enabled. True by default.
49
48
  # It can be set to an array that will enable params authentication only for the
@@ -245,9 +244,8 @@ Devise.setup do |config|
245
244
  # Configure extension for devise
246
245
 
247
246
  # How long should the user have to enter their token. To change the default, uncomment and change the below:
248
- #config.otp_authentication_timeout = 3.minutes
247
+ # config.otp_authentication_timeout = 3.minutes
249
248
 
250
249
  # Change time drift settings for valid token values. To change the default, uncomment and change the below:
251
- #config.otp_authentication_time_drift = 3
252
-
250
+ # config.otp_authentication_time_drift = 3
253
251
  end
File without changes
File without changes
@@ -4,5 +4,5 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '7854ba4c663086c191afbc2e05384503b5529fa2c8e51417539db1cbe7c68e8490e9d57a1d908d4e82816a522edb97f71a8de9233272a5598534a38ef1b08697'
8
- Dummy::Application.config.secret_key_base = '7854ba4c663086c191afbc2e05384503b5529fa2c8e51417539db1cbe7c68e8490e9d57a1d908d4e82816a522edb97f71a8de9233272a5598534a38ef1b08697'
7
+ Dummy::Application.config.secret_token = "7854ba4c663086c191afbc2e05384503b5529fa2c8e51417539db1cbe7c68e8490e9d57a1d908d4e82816a522edb97f71a8de9233272a5598534a38ef1b08697"
8
+ Dummy::Application.config.secret_key_base = "7854ba4c663086c191afbc2e05384503b5529fa2c8e51417539db1cbe7c68e8490e9d57a1d908d4e82816a522edb97f71a8de9233272a5598534a38ef1b08697"
@@ -1,6 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
3
+ Dummy::Application.config.session_store :cookie_store, key: "_dummy_session"
4
4
 
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
@@ -5,7 +5,7 @@
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters :format => [:json]
8
+ wrap_parameters format: [:json]
9
9
  end
10
10
 
11
11
  # Disable root element in JSON by default.
File without changes
@@ -2,5 +2,5 @@ Dummy::Application.routes.draw do
2
2
  devise_for :users
3
3
 
4
4
  resources :posts
5
- root :to => 'posts#index'
5
+ root to: "posts#index"
6
6
  end
data/test/dummy/config.ru CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require ::File.expand_path("../config/environment", __FILE__)
4
4
  run Dummy::Application
File without changes