devise-twilio-verify 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fc8af9da1425014bde8b7bb0294faae2edc0b47e9cf635ec07b9b5300fbc6fb
4
- data.tar.gz: 99440a90447a85010a85c5fe77c37dab1a69969b20c855016291b32900632084
3
+ metadata.gz: 474f80f30182d50c461662ac4927abeb8a7e896b7f2bc92b538073e1538db06f
4
+ data.tar.gz: 27dfc2219f247de90a1bfb7d32546050cfb505f1f0afefe1b5d442ce00500a6b
5
5
  SHA512:
6
- metadata.gz: e24dd31ecee36c3366391eda08bec3e119df74e2af8c7a48c49eff9453fd572c5203aa81efd026eca2599f0001648933dda91e2fac8a26d4539a05410ac24d43
7
- data.tar.gz: 676fbd754e2fd134b38e931902ac2e730b009f11865cc3e084f2b8678cbb20c965a720a85087523b47ff8098327c98d4b06e2b443a43406aec164bd7f5e65396
6
+ metadata.gz: 5c553ebfcecf53b015eb4767c4ff3acba7386eb861ad1854ee9c712d53b7d20f1fdf37e6a657837730ffa7a60c2fc4cd604b7cd3c49dadc4854b14427659fe01
7
+ data.tar.gz: 2b31f9e9319e89a49db84b6aa6cf34e022c781dba6ed14d185ebf37446928e37379589b42c5ced9f4b939124896c9ca6a76e6a37ca140681b47d379697eb20c9
@@ -8,13 +8,17 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [2.5, 2.6, 2.7, "3.0", 3.1, head]
11
+ ruby: [2.7, "3.0", 3.1, 3.2, 3.3, head]
12
12
  gemfile: [rails_5_2, rails_6]
13
13
  exclude:
14
14
  - ruby: "3.0"
15
15
  gemfile: rails_5_2
16
16
  - ruby: 3.1
17
17
  gemfile: rails_5_2
18
+ - ruby: 3.2
19
+ gemfile: rails_5_2
20
+ - ruby: 3.3
21
+ gemfile: rails_5_2
18
22
  - ruby: head
19
23
  gemfile: rails_5_2
20
24
  continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --color
2
- --require ./spec/spec_helper
2
+ --require ./spec/spec_helper
data/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.0] - 2024-12-21
9
+
10
+ ### Changed
11
+
12
+ - Bugfix to not return any users when the mobile phone number is missing when querying for a user with `User.find_by_mobile_phone`
13
+ - Fixed test coverage from the initial fork from Authy to Twilio Verify API
14
+ - Disabled specs for TOTP setup. Currently there's just a method exposed to generate a code with the Twilio Verify service. Rails apps consuming the gem are expected to to generate a qr code with this code and present it to the user to scan. This feature can be added in the future
15
+ - Restored original flash message behavior from authy-devise on a few endpoints. Despite this being the original behavior, due to this change I will bump versioning as minor version release for Rails apps that did not migrate from devise-authy
16
+
8
17
  ## [0.1.1] - 2023-04-12
9
18
 
10
19
  ### Changed
@@ -34,7 +34,7 @@ class Devise::DeviseTwilioVerifyController < DeviseController
34
34
  verification_check = false
35
35
  end
36
36
 
37
- # Hack to reproduce authy functionality of being able to verify 2FA via SMS or TOTP
37
+ # Reproduce authy functionality of being able to verify 2FA via SMS or TOTP
38
38
  # not ideal as there could be network delays, but there is currently no alternative
39
39
  if !verification_check && @resource.twilio_totp_factor_sid.present?
40
40
  verification_check = TwilioVerifyService.verify_totp_token(@resource, params[:token])
@@ -51,6 +51,15 @@ class Devise::DeviseTwilioVerifyController < DeviseController
51
51
  end
52
52
  end
53
53
 
54
+ def GET_enable_twilio_verify
55
+ if resource.twilio_verify_enabled?
56
+ set_flash_message(:notice, :already_enabled)
57
+ redirect_to after_twilio_verify_enabled_path_for(resource)
58
+ else
59
+ render :enable_twilio_verify
60
+ end
61
+ end
62
+
54
63
  # enable 2fa
55
64
  def POST_enable_twilio_verify
56
65
  if resource.update(twilio_verify_enabled: true)
@@ -64,7 +73,13 @@ class Devise::DeviseTwilioVerifyController < DeviseController
64
73
  # Disable 2FA
65
74
  def POST_disable_twilio_verify
66
75
  resource.assign_attributes(twilio_verify_enabled: false)
67
- resource.save(:validate => false)
76
+ if resource.save(validate: false)
77
+ forget_device
78
+ set_flash_message(:notice, :disabled)
79
+ else
80
+ set_flash_message(:error, :not_disabled)
81
+ end
82
+
68
83
  redirect_to after_twilio_verify_disabled_path_for(resource)
69
84
  end
70
85
 
@@ -83,9 +98,9 @@ class Devise::DeviseTwilioVerifyController < DeviseController
83
98
 
84
99
  verification_check = TwilioVerifyService.verify_sms_token(@resource.mobile_phone, params[:token])
85
100
 
86
- self.resource.twilio_verify_enabled = token.ok?
101
+ self.resource.twilio_verify_enabled = verification_check.status == 'approved'
87
102
 
88
- if token.ok? && self.resource.save
103
+ if verification_check.status == 'approved' && self.resource.save
89
104
  remember_device(@resource.id) if params[:remember_device].to_i == 1
90
105
  record_twilio_verify_authentication
91
106
  set_flash_message(:notice, :enabled)
@@ -46,4 +46,7 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency "generator_spec"
47
47
  spec.add_development_dependency "database_cleaner", "~> 1.7"
48
48
  spec.add_development_dependency "factory_bot_rails", "~> 5.1.1"
49
+ spec.add_development_dependency "mutex_m", "~> 0.3.0"
50
+ spec.add_development_dependency "drb", "~> 2.2.1"
51
+ spec.add_development_dependency "observer", "~> 0.1.2"
49
52
  end
@@ -10,6 +10,8 @@ module Devise
10
10
 
11
11
  module ClassMethods
12
12
  def find_by_mobile_phone(mobile_phone)
13
+ return if mobile_phone.blank?
14
+
13
15
  where(mobile_phone: mobile_phone).first
14
16
  end
15
17
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeviseTwilioVerify
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -4,14 +4,13 @@ class DeviseTwilioVerifyAddTo<%= table_name.camelize %> < ActiveRecord::Migratio
4
4
  t.string :authy_id
5
5
  t.datetime :last_sign_in_with_twilio_verify
6
6
  t.boolean :twilio_verify_enabled, :default => false
7
+ t.string :twilio_totp_factor_sid
7
8
  end
8
-
9
- add_index :<%= table_name %>, :authy_id
10
9
  end
11
10
 
12
11
  def self.down
13
12
  change_table :<%= table_name %> do |t|
14
- t.remove :authy_id, :last_sign_in_with_twilio_verify, :twilio_verify_enabled
13
+ t.remove :authy_id, :last_sign_in_with_twilio_verify, :twilio_verify_enabled, :twilio_totp_factor_sid
15
14
  end
16
15
  end
17
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-twilio-verify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Wolff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-13 00:00:00.000000000 Z
11
+ date: 2024-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -262,6 +262,48 @@ dependencies:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
264
  version: 5.1.1
265
+ - !ruby/object:Gem::Dependency
266
+ name: mutex_m
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: 0.3.0
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: 0.3.0
279
+ - !ruby/object:Gem::Dependency
280
+ name: drb
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: 2.2.1
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: 2.2.1
293
+ - !ruby/object:Gem::Dependency
294
+ name: observer
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: 0.1.2
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: 0.1.2
265
307
  description: Twilio Verify plugin to add two factor authentication to Devise. This
266
308
  gem is meant to make migrating from authy to twilio verify as simple as possible,
267
309
  please see the README for details.