twilio_phone_verification 0.1.18 → 1.0.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 +4 -4
- data/README.md +45 -8
- data/lib/twilio_phone_verification/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07af1f70b989c194fa8eeaa0b8518726fd329433
|
4
|
+
data.tar.gz: 44096f2a57fd56fa1b7da191d00e9cf7c58c1f32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 734d0d27bb6f16ae5dd739d378823610257763cd8e74b9e3804355b4e157460cb602d739aa502cc47de688059e829da69d5c8cad54f64abd77d22c6ad3aaec83
|
7
|
+
data.tar.gz: bb561c9aaf7fefdc92a3114226dfb37396e8c7067408d163050c4df1600675b1df2894317e76f7cb29aec39a88b70f835c01d9f31d32b7a5269c575569c70e48
|
data/README.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# TwilioPhoneVerification
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
`twilio_phone_verification` is a gem for Ruby on Rails applications which you can use to verify user's phone numbers using twilio.com
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
10
8
|
|
11
9
|
```ruby
|
12
|
-
gem
|
10
|
+
gem "twilio_phone_verification"
|
13
11
|
```
|
14
12
|
|
15
13
|
And then execute:
|
@@ -20,15 +18,54 @@ Or install it yourself as:
|
|
20
18
|
|
21
19
|
$ gem install twilio_phone_verification
|
22
20
|
|
21
|
+
## Configuration
|
22
|
+
|
23
|
+
First of all you need to install config files. You can to it using this command:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
rails g twilio_phone_verification:install [USER_CLASS]
|
27
|
+
```
|
28
|
+
|
29
|
+
### Example
|
30
|
+
|
31
|
+
```bash
|
32
|
+
rails g twilio_phone_verification:install User
|
33
|
+
```
|
34
|
+
|
35
|
+
It wil generate two files `config/initializers/twilio_phone_verification.rb` and `add_phone_to_users` migration. You will have to set your secret keys in initializer file or put it in `.env` file.
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
TwilioPhoneVerification.configure do |config|
|
39
|
+
config.account_sid = ENV.fetch("TWILIO_ACCOUNT_SID") # Paste your twilio account id here
|
40
|
+
config.auth_token = ENV.fetch("TWILIO_AUTH_TOKEN") # Paste your twilio auth token here
|
41
|
+
config.from = ENV.fetch("TWILIO_NUMBER") # Paste your twilio number here
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
After this you will need to add concern to your `model`
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
class User < ActiveRecord::Base
|
49
|
+
include TwilioPhoneVerification::Phonable
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
That's it!
|
54
|
+
|
23
55
|
## Usage
|
24
56
|
|
25
|
-
|
57
|
+
Now you can call some new methods on your model
|
26
58
|
|
27
|
-
|
59
|
+
| Method | Description |
|
60
|
+
|---|---|
|
61
|
+
| **`phone_confirmed?`** | Returns `true` if phone was confirmed, or `false` if it wasn't. |
|
62
|
+
| **`send_phone_confirmation`** | Generate and send generated code to user's phone number. Returns `{success: true}` if code was sent, or `false` if it wasn't |
|
63
|
+
| **`confirm_phone_by_code(code)`** | Returns `true` and makes user's phone verified if code was correct, otherwise `false`. |
|
64
|
+
| **`confirm_phone`** | Confirms user's phone number without sending a code |
|
28
65
|
|
29
|
-
|
66
|
+
If one of these methods returns `false`, you can see error in `.errors` method. (exception: `phone_confirmed`)
|
30
67
|
|
31
|
-
|
68
|
+
**Note:** Code can be sent only once per 60 seconds, if you call `send_phone_confirmation` few times, it will send only one code.
|
32
69
|
|
33
70
|
## Contributing
|
34
71
|
|