Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.16
0.3.16.5
22 changes: 11 additions & 11 deletions app/controllers/devise/checkga_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Devise::CheckgaController < Devise::SessionsController
prepend_before_filter :devise_resource, :only => [:show]
prepend_before_filter :require_no_authentication, :only => [ :show, :update ]
prepend_before_action :devise_resource, only: [:show]
prepend_before_action :require_no_authentication, only: %i[show update]

include Devise::Controllers::Helpers

Expand All @@ -16,19 +16,19 @@ def show
def update
resource = resource_class.find_by_gauth_tmp(params[resource_name]['tmpid'])

if not resource.nil?
if !resource.nil?

if resource.validate_token(params[resource_name]['gauth_token'].to_i)
set_flash_message(:notice, :signed_in) if is_navigational_format?
sign_in(resource_name,resource)
warden.manager._run_callbacks(:after_set_user, resource, warden, {:event => :authentication})
respond_with resource, :location => after_sign_in_path_for(resource)
sign_in(resource_name, resource)
warden.manager._run_callbacks(:after_set_user, resource, warden, { event: :authentication })
respond_with resource, location: after_sign_in_path_for(resource)

if not resource.class.ga_remembertime.nil?
unless resource.class.ga_remembertime.nil?
cookies.signed[:gauth] = {
:value => resource.email << "," << Time.now.to_i.to_s,
:secure => !(Rails.env.test? || Rails.env.development?),
:expires => (resource.class.ga_remembertime + 1.days).from_now
value: resource.email << ',' << Time.now.to_i.to_s,
secure: !(Rails.env.test? || Rails.env.development?),
expires: (resource.class.ga_remembertime + 1.days).from_now
}
end
else
Expand All @@ -47,4 +47,4 @@ def update
def devise_resource
self.resource = resource_class.new
end
end
end
16 changes: 9 additions & 7 deletions app/controllers/devise/displayqr_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Devise::DisplayqrController < DeviseController
prepend_before_filter :authenticate_scope!, :only => [:show, :update, :refresh]
prepend_before_action :authenticate_scope!, only: %i[show update refresh]

include Devise::Controllers::Helpers

Expand All @@ -23,26 +23,27 @@ def update

if resource.set_gauth_enabled(params[resource_name]['gauth_enabled'])
set_flash_message :notice, (resource.gauth_enabled? ? :enabled : :disabled)
sign_in scope, resource, :bypass => true
sign_in scope, resource, bypass: true
redirect_to stored_location_for(scope) || :root
else
render :show
end
end

def refresh
unless resource.nil?
if resource.nil?
redirect_to :root
else
resource.send(:assign_auth_secret)
resource.save
set_flash_message :notice, :newtoken
sign_in scope, resource, :bypass => true
sign_in scope, resource, bypass: true
redirect_to [resource_name, :displayqr]
else
redirect_to :root
end
end

private

def scope
resource_name.to_sym
end
Expand All @@ -55,10 +56,11 @@ def authenticate_scope!
# 7/2/15 - Unsure if this is used anymore - @xntrik
def resource_params
return params.require(resource_name.to_sym).permit(:gauth_enabled) if strong_parameters_enabled?

params
end

def strong_parameters_enabled?
defined?(ActionController::StrongParameters)
end
end
end
14 changes: 7 additions & 7 deletions devise_google_authenticator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)

Gem::Specification.new do |s|
s.name = "devise_google_authenticator"
s.version = "0.3.16"
s.authors = ["Christian Frichot"]
s.date = "2015-02-08"
s.version = "0.3.16.5"
s.authors = ["Calos Chen"]
s.date = "2023-06-13"
s.description = "Devise Google Authenticator Extension, for adding Google's OTP to your Rails apps!"
s.email = "xntrik@gmail.com"
s.email = "calos.chen@splashtop.com"
s.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
Expand All @@ -17,15 +17,15 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.summary = "Devise Google Authenticator Extension"

s.required_ruby_version = '>= 1.9.2'
# s.required_ruby_version = '>= 1.9.2'
# s.required_rubygems_version = '>= 2.1.0'

{
# 'railties' => '~> 3.0',
# removed the following to try and get past this bundle update not finding compatible versions for gem issue
# 'actionmailer' => '>= 3.0',
# 'actionmailer' => '>= 3.0',
#'actionmailer' => '~> 3.2',# '>= 3.2.12',
'devise' => '~> 3.2',
# 'devise' => '~> 3.2',
'rotp' => '~> 1.6'
}.each do |lib, version|
s.add_runtime_dependency(lib, *version)
Expand Down
2 changes: 1 addition & 1 deletion lib/devise_google_authenticatable/rails.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module DeviseGoogleAuthenticator
class Engine < ::Rails::Engine # :nodoc:
ActionDispatch::Callbacks.to_prepare do
ActiveSupport::Reloader.to_prepare do
DeviseGoogleAuthenticator::Patches.apply
end

Expand Down
4 changes: 2 additions & 2 deletions lib/devise_google_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Devise # :nodoc:
@@ga_remembertime = 1.month

mattr_accessor :ga_appname
@@ga_appname = Rails.application.class.parent_name
@@ga_appname = Rails.application.class.module_parent.name

mattr_accessor :ga_bypass_signup
@@ga_bypass_signup = false
Expand All @@ -36,4 +36,4 @@ module DeviseGoogleAuthenticator
require 'devise_google_authenticatable/controllers/helpers'
ActionView::Base.send :include, DeviseGoogleAuthenticator::Controllers::Helpers

Devise.add_module :google_authenticatable, :controller => :google_authenticatable, :model => 'devise_google_authenticatable/models/google_authenticatable', :route => :displayqr
Devise.add_module :google_authenticatable, :controller => :google_authenticatable, :model => 'devise_google_authenticatable/models/google_authenticatable', :route => :displayqr