devise_sms_confirmable 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7da634ddbe05a536e69cfc4223581ca87f6f22e7aa35e6bbaaa8f8927d16cce
4
- data.tar.gz: e779c465edf5eda673f6a90cd50b5273309c903adaebc272e3a500df3526e50d
3
+ metadata.gz: '049bae282e2af2b808e51365d2477664439dc89e7847b92f3242c8b6334843fe'
4
+ data.tar.gz: d0b596cfe10169aaa6cd38aaf9009600d102990519c25b24baaa22c5a11a139c
5
5
  SHA512:
6
- metadata.gz: 85925719b646dd4e7482c4d1bc9b8889a7249416504e0884fbead9dc0b4b08499791061552250e5fa326d7789da8a7d108621e521f6c7f27b6a65e071fea60fc
7
- data.tar.gz: d87a5c77aef9b90a4e07e29629cc91ce841395538d67e30b80b7ea507ef2686f6f8636c059f688181a2125389c977232d94579b01a59dd614bcb3f5ec5395d29
6
+ metadata.gz: a35a12708450aa0d22d91a220487964df17219393ceac24110819d9bbffa2657cb4f8a562ea0854b4fcdc3461492d04bae947de3defbd252a26c7b32f4f2d46c
7
+ data.tar.gz: 6734e8771b51f17a7763af0fe16d8f28fb792d4ad00829e90f9db8b562ae1c59ca120e3c69199a671c2976540aebeab407c03273a199f1034978f9b77eda43f5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devise_sms_confirmable (0.1.2)
4
+ devise_sms_confirmable (0.1.3)
5
5
  devise (>= 4.6.2)
6
6
  rails (~> 5.1.4)
7
7
  textris (~> 0.7)
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # DeviseSmsConfirmable
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/devise_sms_confirmable`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ DeviseSmsConfirmable is a module provide SMS confirmation. The user will receive an SMS with a token that can be entered on the site to activate the account. You can handle SMS's Message template as Devise handles ActionMailer's template.
6
4
 
7
5
  ## Installation
8
-
9
- Add this line to your application's Gemfile:
6
+ Installation for Rails ~> 5.1.4 and Devise ~> 4.6.2
7
+ Add this line to your application's Gemfile (and Devise and TwilioRuby if you weren't using them):
10
8
 
11
9
  ```ruby
10
+ gem 'devise'
12
11
  gem 'devise_sms_confirmable'
12
+ gem 'twilio-ruby'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -21,14 +21,75 @@ Or install it yourself as:
21
21
  $ gem install devise_sms_confirmable
22
22
 
23
23
  ## Usage
24
+ To use it, simply specify your DeviseSmsConfirmable configuration in ```config/initializers/devise.rb```:
25
+
26
+ ```ruby
27
+ # Load the module for SMS confirmation
28
+ require 'devise_sms_confirmable'
29
+ # Default source phone number
30
+ config.sms_sender = 'some_e164_phone_number'
31
+ ```
32
+
33
+ ### Configuring Models
34
+ Add :sms_confirmable option to The Devise method in your models.
35
+
36
+ ```ruby
37
+ devise :database_authenticatable, :sms_confirmable
38
+
39
+ ```
40
+
41
+ ### Add columns to model
42
+ ```ruby
43
+ t.string :phone, null: false, default: ""
44
+ t.string :sms_confirmation_token
45
+ t.datetime :sms_confirmed_at
46
+ t.datetime :sms_confirmation_sent_at
47
+ # t.string :unconfirmed_phone # Only if using reconfirmable
48
+ ```
49
+
50
+ ### Allow models to sign in using their phone number
51
+
52
+ ```ruby
53
+ config.authentication_keys = [:phone]
54
+ ```
55
+
56
+ ## Configuring twilio-ruby
57
+
58
+ config/initializers/twilio.rb
59
+
60
+ ### Choosing and chaining delivery methods
61
+ devise_sms_confirmable use [textris](https://github.com/visualitypl/textris) for the delivery system. See textris for details.
62
+ The following is a sample (quoted from textris) using twilio.
24
63
 
25
- TODO: Write usage instructions here
64
+ ```ruby
65
+ # Send messages via the Twilio REST API
66
+ config.textris_delivery_method = :twilio
67
+
68
+ # Don't send anything, log messages into Rails logger
69
+ config.textris_delivery_method = :log
70
+
71
+ # Don't send anything, access your messages via Textris::Base.deliveries
72
+ config.textris_delivery_method = :test
73
+ ```
26
74
 
27
- ## Development
75
+ ### Twilio
76
+ textris connects with the Twilio API using twilio-ruby gem. It does not, however, install the gem for you. If you don't have it yet, add the twilio-ruby gem to Gemfile:
28
77
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
78
+ ```ruby
79
+ gem 'twilio-ruby'
80
+ ```
81
+
82
+ Then, pre-configure the twilio-ruby settings by creating the config/initializers/twilio.rb file:
83
+
84
+ ```ruby
85
+
86
+ Twilio.configure do |config|
87
+ config.account_sid = 'some_sid'
88
+ config.auth_token = 'some_auth_token'
89
+ end
90
+ ```
30
91
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
92
+ To use Twilio's Copilot use twilio_messaging_service_sid in place of from when sending a text or setting defaults.
32
93
 
33
94
  ## Contributing
34
95
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  if defined?(Textris)
4
4
  class Devise::Texter < Textris::Base
5
- default from: "+48666777888"
6
5
 
7
6
  def confirmation_instructions(record, token, opts={})
8
7
  @token = token
@@ -10,7 +9,7 @@ if defined?(Textris)
10
9
 
11
10
  headers = { to: @resource.phone }.merge(opts)
12
11
 
13
- text to: headers[:to]
12
+ send_sms(headers)
14
13
  end
15
14
 
16
15
  def reset_password_instructions(record, token, opts={})
@@ -19,7 +18,7 @@ if defined?(Textris)
19
18
 
20
19
  headers = { to: @resource.phone }.merge(opts)
21
20
 
22
- text to: headers[:to]
21
+ send_sms(headers)
23
22
  end
24
23
 
25
24
  def unlock_instructions(record, token, opts={})
@@ -28,7 +27,7 @@ if defined?(Textris)
28
27
 
29
28
  headers = { to: @resource.phone }.merge(opts)
30
29
 
31
- text to: headers[:to]
30
+ send_sms(headers)
32
31
  end
33
32
 
34
33
  def phone_changed(record, token, opts={})
@@ -37,7 +36,7 @@ if defined?(Textris)
37
36
 
38
37
  headers = { to: @resource.phone }.merge(opts)
39
38
 
40
- text to: headers[:to]
39
+ send_sms(headers)
41
40
  end
42
41
 
43
42
  def password_change(record, token, opts={})
@@ -46,7 +45,11 @@ if defined?(Textris)
46
45
 
47
46
  headers = { to: @resource.phone }.merge(opts)
48
47
 
49
- text to: headers[:to]
48
+ send_sms(headers)
49
+ end
50
+
51
+ def send_sms(headers)
52
+ text(to: headers[:to], from: Devise.sms_sender)
50
53
  end
51
54
  end
52
55
  end
@@ -5,11 +5,11 @@ require "devise_sms_confirmable/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "devise_sms_confirmable"
7
7
  spec.version = DeviseSmsConfirmable::VERSION
8
- spec.authors = ["matsutani"]
8
+ spec.authors = ["uuushiro"]
9
9
  spec.email = ["yushiro.ma2ta2.21@gmail.com"]
10
10
 
11
- spec.summary = %q{Module provide sms confirmation.}
12
- spec.description = %q{Module provide sms confirmation.}
11
+ spec.summary = %q{Module provide sms confirmation.You can handle SMS Message template as Devise handles ActionMailer template.}
12
+ spec.description = %q{Module provide sms confirmation.You can handle SMS Message template as Devise handles ActionMailer template.}
13
13
  spec.homepage = "https://github.com/uuushiro/devise_sms_confirmable"
14
14
  spec.license = "MIT"
15
15
 
@@ -1,3 +1,3 @@
1
1
  module DeviseSmsConfirmable
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_sms_confirmable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
- - matsutani
7
+ - uuushiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-02 00:00:00.000000000 Z
11
+ date: 2019-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -150,7 +150,8 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
- description: Module provide sms confirmation.
153
+ description: Module provide sms confirmation.You can handle SMS Message template as
154
+ Devise handles ActionMailer template.
154
155
  email:
155
156
  - yushiro.ma2ta2.21@gmail.com
156
157
  executables: []
@@ -205,5 +206,6 @@ rubyforge_project:
205
206
  rubygems_version: 2.7.6
206
207
  signing_key:
207
208
  specification_version: 4
208
- summary: Module provide sms confirmation.
209
+ summary: Module provide sms confirmation.You can handle SMS Message template as Devise
210
+ handles ActionMailer template.
209
211
  test_files: []