devise_instant2fa 1.0.1 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b1449ef40141b27a50dd0a46074bcda15bd6423
4
- data.tar.gz: e325998b8f174692e00708b3fb29941f25c15ce1
3
+ metadata.gz: d15464b931444b3e934467930193417fa6e724d8
4
+ data.tar.gz: 0ddeb8af1ae65c690acca5e606ede0f3ee8f1733
5
5
  SHA512:
6
- metadata.gz: 846b20b9d1dccd64c7a43eaabe210e03eac21551c645c3e23bdd4391fd938be1c5dc8b0053b6ffcc6409de446b887ab85b997cfdaf18cb65ebbaa3d428d38a2e
7
- data.tar.gz: 83c40520260431adef2ff92b4179ebbf715b3d04d190b557ce205ec9bc6326794a2db48fda7b981c32179b5415de20ceb6fb680abb8ccbcae780135cf506f333
6
+ metadata.gz: c999159588141a64c9879a89059904ae6414e76d08bb8922576cd28e3fc424480da355d0906842de5b40348de19d0b9ff2d01f15ea5954807d1eae2a7dcebd8c
7
+ data.tar.gz: d958263da1a298103f92859a6fd678667a6bd4cfee1dfc7f7d0f39210526912101e823b97420e7c13582e1e4152d66759371cc61fe9d9d7fcd6765ffa90d24ec
@@ -0,0 +1,12 @@
1
+ class DeviseInstant2fa::PasswordsController < Devise::PasswordsController
2
+ def sign_in(resource_or_scope, *args)
3
+ resource = args.last || resource_or_scope
4
+
5
+ if resource.respond_to?(:with_instant2fa_verification_url) && resource.with_instant2fa_verification_url
6
+
7
+ true
8
+ else
9
+ super
10
+ end
11
+ end
12
+ end
@@ -35,7 +35,10 @@ module DeviseInstant2fa
35
35
  NEED_AUTHENTICATION = 'need_two_factor_authentication'
36
36
  HOSTED_PAGE_URL = 'hosted_page_url'
37
37
 
38
+ autoload :Mapping, 'devise_instant2fa/mapping'
39
+
38
40
  module Controllers
41
+ autoload :Passwords, 'devise_instant2fa/controllers/passwords'
39
42
  autoload :Helpers, 'devise_instant2fa/controllers/helpers'
40
43
  end
41
44
 
@@ -44,18 +47,9 @@ module DeviseInstant2fa
44
47
  end
45
48
  end
46
49
 
47
- module Devise
48
- module Models
49
- module Instant2faAuthenticatable
50
- def instant2fa_settings_url
51
- Instant2fa.create_settings(self.id)
52
- end
53
- end
54
- end
55
- end
50
+ require 'devise_instant2fa/routes'
51
+ require 'devise_instant2fa/rails'
52
+ require 'devise_instant2fa/models/instant2fa_authenticatable'
56
53
 
57
54
  Devise.add_module :instant2fa_authenticatable, :controller => :instant2fa, :route => :instant2fa
58
55
 
59
- require 'devise_instant2fa/hooks/instant2fa_authenticatable'
60
- require 'devise_instant2fa/routes'
61
- require 'devise_instant2fa/rails'
@@ -1,11 +1,11 @@
1
1
  require 'instant2fa'
2
2
 
3
3
  Warden::Manager.after_authentication do |user, auth, options|
4
- begin
5
- hosted_page_url = Instant2fa.create_verification(user.id.to_s)
6
- auth.session(options[:scope])[DeviseInstant2fa::NEED_AUTHENTICATION] = true
7
- auth.session(options[:scope])[DeviseInstant2fa::HOSTED_PAGE_URL] = hosted_page_url
8
- auth.session(options[:scope])[:id] = user.id
9
- rescue Instant2fa::Errors::MFANotEnabled
4
+ if user.respond_to?(:with_instant2fa_verification_url)
5
+ if hosted_page_url = user.with_instant2fa_verification_url
6
+ auth.session(options[:scope])[DeviseInstant2fa::NEED_AUTHENTICATION] = true
7
+ auth.session(options[:scope])[DeviseInstant2fa::HOSTED_PAGE_URL] = hosted_page_url
8
+ auth.session(options[:scope])[:id] = user.id
9
+ end
10
10
  end
11
11
  end
@@ -0,0 +1,11 @@
1
+ module DeviseInstant2fa
2
+ module Mapping
3
+ private
4
+
5
+ def default_controllers(options)
6
+ options[:controllers] ||= {}
7
+ options[:controllers][:passwords] ||= "devise_instant2fa/passwords"
8
+ super
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require 'devise_instant2fa/hooks/instant2fa_authenticatable'
2
+
3
+ module Devise
4
+ module Models
5
+ module Instant2faAuthenticatable
6
+ def instant2fa_settings_url
7
+ Instant2fa.create_settings(self.id.to_s)
8
+ end
9
+
10
+ def with_instant2fa_verification_url
11
+ begin
12
+ hosted_page_url = Instant2fa.create_verification(self.id.to_s)
13
+ return hosted_page_url
14
+ rescue Instant2fa::Errors::MFANotEnabled
15
+ end
16
+
17
+ return false
18
+ end
19
+ end
20
+ end
21
+ end
@@ -3,5 +3,13 @@ module DeviseInstant2fa
3
3
  ActiveSupport.on_load(:action_controller) do
4
4
  include DeviseInstant2fa::Controllers::Helpers
5
5
  end
6
+
7
+ ActiveSupport.on_load(:action_view) do
8
+ include DeviseInstant2fa::Views::Helpers
9
+ end
10
+
11
+ config.after_initialize do
12
+ Devise::Mapping.send :prepend, DeviseInstant2fa::Mapping
13
+ end
6
14
  end
7
15
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseInstant2fa
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_instant2fa
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Pollak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-17 00:00:00.000000000 Z
11
+ date: 2016-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -151,12 +151,15 @@ files:
151
151
  - README.md
152
152
  - Rakefile
153
153
  - app/controllers/devise/instant2fa_controller.rb
154
+ - app/controllers/devise_instant2fa/passwords_controller.rb
154
155
  - app/views/devise/instant2fa/show.html.erb
155
156
  - config/locales/en.yml
156
157
  - devise_instant2fa.gemspec
157
158
  - lib/devise_instant2fa.rb
158
159
  - lib/devise_instant2fa/controllers/helpers.rb
159
160
  - lib/devise_instant2fa/hooks/instant2fa_authenticatable.rb
161
+ - lib/devise_instant2fa/mapping.rb
162
+ - lib/devise_instant2fa/models/instant2fa_authenticatable.rb
160
163
  - lib/devise_instant2fa/rails.rb
161
164
  - lib/devise_instant2fa/routes.rb
162
165
  - lib/devise_instant2fa/version.rb