devise_phone 0.0.1663 → 0.0.1664
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +8 -21
- data/lib/devise_phone/version.rb +1 -1
- data/lib/models/phone.rb +2 -74
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4fe75060a2fa6b492f130e3aaf39369469cc436
|
4
|
+
data.tar.gz: 45ae37d053f9b0d3c99c70ba93424e3283c7a223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30914f56f9c9d1d5c517984fdd8045865c1ce9240ab92c76370a0f517118fad01c95bab7f1922edfe6282a5165d00e91226dc8ea5e025674f90036818708f4a0
|
7
|
+
data.tar.gz: 5bd8860f3b119ebff979f70d818f75b538f892f3f1023c791481479e2b916be1453f0a611f82d3ae296fadc1306b3058e0d39c6aa18ed867849910861697adaf
|
data/README.rdoc
CHANGED
@@ -27,27 +27,14 @@ When you are done, you are ready to add DevisePhone to any of your Devise models
|
|
27
27
|
|
28
28
|
Replace MODEL by the class name you want to add DevisePhone, like User, Admin, etc. This will add the :phone flag to your model's Devise modules. The generator will also create a migration file (if your ORM support them). Continue reading this file to understand exactly what the generator produces and how to use it.
|
29
29
|
|
30
|
-
In your
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
test:
|
39
|
-
secret_key_base: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
40
|
-
twilio_sid: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
41
|
-
twilio_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
42
|
-
twilio_phone_number: 12345678
|
43
|
-
|
44
|
-
# Do not keep production secrets in the repository,
|
45
|
-
# instead read values from the environment.
|
46
|
-
production:
|
47
|
-
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
48
|
-
twilio_sid: <%= ENV["TWILIO_SID"] %>
|
49
|
-
twilio_token: <%= ENV["TWILIO_TOKEN"] %>
|
50
|
-
twilio_phone_number: <%= ENV["TWILIO_PHONE_NUMBER"] %>
|
30
|
+
In your config/environments, please specify your twilio_sid, twilio_token, and twilio_phone_number, and twilio_message_body (use #{verification_code} to include the phone verification code of the user) :
|
31
|
+
|
32
|
+
dconfig.twilio = {
|
33
|
+
sid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
|
34
|
+
token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
|
35
|
+
phone_number: '123455678',
|
36
|
+
message_body: "Hi! This is from company u asked for. Your verification code is #{verification_code}"
|
37
|
+
}
|
51
38
|
|
52
39
|
== Configuring views
|
53
40
|
|
data/lib/devise_phone/version.rb
CHANGED
data/lib/models/phone.rb
CHANGED
@@ -2,30 +2,6 @@ require "devise_phone/hooks"
|
|
2
2
|
|
3
3
|
module Devise
|
4
4
|
module Models
|
5
|
-
# SmsActivable is responsible to verify if an account is already confirmed to
|
6
|
-
# sign in, and to send sms with confirmation instructions.
|
7
|
-
# Confirmation instructions are sent to the user phone after creating a
|
8
|
-
# record and when manually requested by a new confirmation instruction request.
|
9
|
-
#
|
10
|
-
# == Options
|
11
|
-
#
|
12
|
-
# Confirmable adds the following options to devise_for:
|
13
|
-
#
|
14
|
-
# * +sms_confirm_within+: the time you want to allow the user to access his account
|
15
|
-
# before confirming it. After this period, the user access is denied. You can
|
16
|
-
# use this to let your user access some features of your application without
|
17
|
-
# confirming the account, but blocking it after a certain period (ie 7 days).
|
18
|
-
# By default confirm_within is 0 days, so the user must confirm before entering.
|
19
|
-
# If you want to allow user to use parts of the site and block others override
|
20
|
-
# sms_confirmation_required? and check manually on selected pages using the
|
21
|
-
# require_sms_activated! helper or sms_confirmed? property on record
|
22
|
-
#
|
23
|
-
# == Examples
|
24
|
-
#
|
25
|
-
# User.find(1).sms_confirm! # returns true unless it's already confirmed
|
26
|
-
# User.find(1).sms_confirmed? # true/false
|
27
|
-
# User.find(1).send_sms_token # manually send token
|
28
|
-
#
|
29
5
|
module Phone
|
30
6
|
extend ActiveSupport::Concern
|
31
7
|
|
@@ -54,34 +30,6 @@ module Devise
|
|
54
30
|
|
55
31
|
private
|
56
32
|
|
57
|
-
# def remember_old_phone_number
|
58
|
-
# puts "phone number changed?: "
|
59
|
-
# puts phone_number_changed?
|
60
|
-
# if phone_number.present?
|
61
|
-
# puts "Old phone number before save:"
|
62
|
-
# puts phone_number
|
63
|
-
# @old_phone_number = phone_number
|
64
|
-
# else
|
65
|
-
# @old_phone_number = nil
|
66
|
-
# end
|
67
|
-
# end
|
68
|
-
|
69
|
-
# def phone_number_changed?
|
70
|
-
# puts "Old phone number after save:"
|
71
|
-
# puts @old_phone_number
|
72
|
-
# if @old_phone_number.present? && phone_number.present?
|
73
|
-
# puts "condition 1"
|
74
|
-
# @old_phone_number != phone_number
|
75
|
-
# elsif @old_phone_number.blank? && phone_number.present?
|
76
|
-
# puts "condition 2"
|
77
|
-
# true
|
78
|
-
# else
|
79
|
-
# puts "condition 3"
|
80
|
-
# set_unverified_phone_attributes
|
81
|
-
# false
|
82
|
-
# end
|
83
|
-
# end
|
84
|
-
|
85
33
|
def private_generate_verification_code_and_send_sms
|
86
34
|
self.phone_verification_code = generate_phone_verification_code
|
87
35
|
set_unverified_phone_attributes
|
@@ -114,16 +62,13 @@ module Devise
|
|
114
62
|
def regenerate_phone_verification_needed?
|
115
63
|
if phone_number.present?
|
116
64
|
if phone_number_changed?
|
117
|
-
# puts "condition 1"
|
118
65
|
true
|
119
66
|
else
|
120
|
-
# puts "condition 2"
|
121
67
|
false
|
122
68
|
end
|
123
69
|
# self.errors.add(:phone_verification_code, :empty_phone_number_field)
|
124
70
|
# false
|
125
71
|
else
|
126
|
-
# puts "condition 3"
|
127
72
|
false
|
128
73
|
end
|
129
74
|
end
|
@@ -153,33 +98,16 @@ module Devise
|
|
153
98
|
twilio_sid = Rails.application.config.twilio[:sid]
|
154
99
|
twilio_token = Rails.application.config.twilio[:token]
|
155
100
|
twilio_phone_number = Rails.application.config.twilio[:phone_number]
|
101
|
+
twilio_message_body = Rails.application.config.twilio[:message_body]
|
156
102
|
|
157
103
|
@twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token
|
158
104
|
|
159
105
|
@twilio_client.account.messages.create(
|
160
106
|
:from => "+1#{twilio_phone_number}",
|
161
107
|
:to => number_to_send_to,
|
162
|
-
:body =>
|
108
|
+
:body => twilio_message_body
|
163
109
|
)
|
164
110
|
end
|
165
|
-
#end of private methods
|
166
|
-
|
167
|
-
# module ClassMethods # 'public' methods for class user
|
168
|
-
|
169
|
-
# def generate_verification_code_and_send_sms
|
170
|
-
# if(phone_verification_needed?)
|
171
|
-
# private_generate_verification_code_and_send_sms
|
172
|
-
# end
|
173
|
-
# self.save!
|
174
|
-
# end
|
175
|
-
|
176
|
-
# def verify_phone_number_with_code_entered(code_entered)
|
177
|
-
# if phone_verification_needed? && (code_entered == self.phone_verification_code)
|
178
|
-
# mark_phone_as_verified!
|
179
|
-
# end
|
180
|
-
# end
|
181
|
-
|
182
|
-
# end #end of ClassMethods
|
183
111
|
|
184
112
|
end
|
185
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_phone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1664
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hubert Theodore
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.4.
|
139
|
+
rubygems_version: 2.4.6
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Send SMS to verify phone number
|