Skip to content

Commit

Permalink
Support Rails 5 and Devise 4.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
strzibny committed Sep 8, 2016
1 parent ab2a9bc commit 5266d0f
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ group :test do
gem "sqlite3"
end

gem "rails", "~> 4.0.0"
gem "rails", "~> 5.0.0"

gem "capybara"
gem 'shoulda'
gem 'selenium-webdriver'

gem 'minitest-reporters', '>= 0.5.0'

end
end
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ Setup the User or Admin model

rails g devise MODEL

Configure your app for authorisation, edit your Controller and add this before_filter:
Configure your app for authorisation, edit your Controller and add this before_action:

before_filter :authenticate_user!
before_action :authenticate_user!

Make sure your "root" route is configured in config/routes.rb

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/devise_otp/credentials_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class DeviseOtp::CredentialsController < DeviseController
helper_method :new_session_path

prepend_before_filter :authenticate_scope!, :only => [:get_refresh, :set_refresh]
prepend_before_filter :require_no_authentication, :only => [ :show, :update ]
prepend_before_action :authenticate_scope!, :only => [:get_refresh, :set_refresh]
prepend_before_action :require_no_authentication, :only => [ :show, :update ]

#
# show a request for the OTP token
Expand Down Expand Up @@ -103,4 +103,4 @@ def failed_refresh
render :refresh
end

end
end
4 changes: 2 additions & 2 deletions app/controllers/devise_otp/tokens_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class DeviseOtp::TokensController < DeviseController
include Devise::Controllers::Helpers

prepend_before_filter :ensure_credentials_refresh
prepend_before_filter :authenticate_scope!
prepend_before_action :ensure_credentials_refresh
prepend_before_action :authenticate_scope!

protect_from_forgery :except => [:clear_persistence, :delete_persistence]

Expand Down
4 changes: 2 additions & 2 deletions devise-otp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_runtime_dependency 'rails', '>= 3.2.6', '< 5'
gem.add_runtime_dependency 'devise', '>= 3.1.0', '< 4.0.0'
gem.add_runtime_dependency 'rails', '>= 3.2.6', '< 5.1'
gem.add_runtime_dependency 'devise', '>= 3.1.0', '< 4.3.0'
gem.add_runtime_dependency 'rotp', '>= 2.0.0'

gem.add_development_dependency "sqlite3"
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
before_action :authenticate_user!
end
1 change: 0 additions & 1 deletion test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ class Application < Rails::Application
config.assets.version = '1.0'
end
end

2 changes: 1 addition & 1 deletion test/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ development:
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: ":memory:"
database: db/test.sqlite3
pool: 5
timeout: 5000

Expand Down
7 changes: 0 additions & 7 deletions test/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict

# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5

# Do not compress assets
config.assets.compress = false

Expand Down
4 changes: 0 additions & 4 deletions test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,4 @@

# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify

# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
end
2 changes: 1 addition & 1 deletion test/dummy/db/migrate/20130125101430_create_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateUsers < ActiveRecord::Migration
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddDeviseToUsers < ActiveRecord::Migration
class AddDeviseToUsers < ActiveRecord::Migration[5.0]
def self.up
change_table(:users) do |t|
## Database authenticatable
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/db/migrate/20130131142320_create_posts.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreatePosts < ActiveRecord::Migration
class CreatePosts < ActiveRecord::Migration[5.0]
def change
create_table :posts do |t|
t.string :title
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class DeviseOtpAddToUsers < ActiveRecord::Migration
class DeviseOtpAddToUsers < ActiveRecord::Migration[5.0]
def self.up
change_table :users do |t|
t.string :otp_auth_secret
Expand All @@ -18,7 +18,7 @@ def self.up
add_index :users, :otp_session_challenge, :unique => true
add_index :users, :otp_challenge_expires
end

def self.down
change_table :users do |t|
t.remove :otp_auth_secret, :otp_recovery_secret, :otp_enabled, :otp_mandatory, :otp_enabled_on, :otp_session_challenge,
Expand Down

0 comments on commit 5266d0f

Please sign in to comment.