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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +70 -9
- data/app/texters/devise/texter.rb +9 -6
- data/devise_sms_confirmable.gemspec +3 -3
- data/lib/devise_sms_confirmable/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '049bae282e2af2b808e51365d2477664439dc89e7847b92f3242c8b6334843fe'
|
4
|
+
data.tar.gz: d0b596cfe10169aaa6cd38aaf9009600d102990519c25b24baaa22c5a11a139c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a35a12708450aa0d22d91a220487964df17219393ceac24110819d9bbffa2657cb4f8a562ea0854b4fcdc3461492d04bae947de3defbd252a26c7b32f4f2d46c
|
7
|
+
data.tar.gz: 6734e8771b51f17a7763af0fe16d8f28fb792d4ad00829e90f9db8b562ae1c59ca120e3c69199a671c2976540aebeab407c03273a199f1034978f9b77eda43f5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# DeviseSmsConfirmable
|
2
2
|
|
3
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 = ["
|
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
|
|
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.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- uuushiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
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: []
|