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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dd1ee38f28c44fc279989736c211932cd4ff274
4
- data.tar.gz: cc3c3fe00e5e54af469068208e3cbd06ad31ac30
3
+ metadata.gz: 07af1f70b989c194fa8eeaa0b8518726fd329433
4
+ data.tar.gz: 44096f2a57fd56fa1b7da191d00e9cf7c58c1f32
5
5
  SHA512:
6
- metadata.gz: 1eea0f671e53932fda758a2ad6b983cb8b44a6bd40188b920df28857ece2f3ae84e93d908ef6ce3af450169ec7a927116911e9358491ff91e1b2bcf08e4d25b2
7
- data.tar.gz: d5682c31ef896ad657c8a54df0b92773ad8700021bf917ed450c3f5b5fb913b32f330768a7bdfc459e241d839ee96022a5e1a4ab638ee33861dd3c8a1e6798c6
6
+ metadata.gz: 734d0d27bb6f16ae5dd739d378823610257763cd8e74b9e3804355b4e157460cb602d739aa502cc47de688059e829da69d5c8cad54f64abd77d22c6ad3aaec83
7
+ data.tar.gz: bb561c9aaf7fefdc92a3114226dfb37396e8c7067408d163050c4df1600675b1df2894317e76f7cb29aec39a88b70f835c01d9f31d32b7a5269c575569c70e48
data/README.md CHANGED
@@ -1,15 +1,13 @@
1
1
  # TwilioPhoneVerification
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/twilio_phone_verification`. 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
+ `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 'twilio_phone_verification'
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
- TODO: Write usage instructions here
57
+ Now you can call some new methods on your model
26
58
 
27
- ## Development
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
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
66
+ If one of these methods returns `false`, you can see error in `.errors` method. (exception: `phone_confirmed`)
30
67
 
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).
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
 
@@ -1,3 +1,3 @@
1
1
  module TwilioPhoneVerification
2
- VERSION = "0.1.18"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio_phone_verification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vishgleb@mail.ru