devise-authy 1.6.0 → 1.7.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 +13 -5
- data/LICENSE.txt +1 -1
- data/README.md +17 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/devise_authy.js +5 -0
- data/app/controllers/devise/devise_authy_controller.rb +21 -5
- data/app/views/devise/verify_authy.html.erb +5 -2
- data/app/views/devise/verify_authy.html.haml +6 -2
- data/authy-devise-demo/app/assets/javascripts/devise_authy.js +5 -0
- data/authy-devise-demo/app/assets/stylesheets/devise_authy.css +4 -4
- data/authy-devise-demo/app/views/devise/devise_authy/verify_authy.html.erb +6 -2
- data/authy-devise-demo/app/views/layouts/application.html.erb +0 -2
- data/authy-devise-demo/config/initializers/devise.rb +5 -5
- data/authy-devise-demo/config/locales/devise.authy.en.yml +5 -2
- data/config/locales/en.yml +2 -1
- data/devise-authy.gemspec +4 -4
- data/lib/devise-authy/controllers/view_helpers.rb +35 -10
- data/lib/devise-authy/routes.rb +1 -0
- data/lib/generators/devise_authy/install_generator.rb +2 -4
- data/spec/controllers/devise_authy_controller_spec.rb +24 -1
- data/spec/rails-app/Gemfile +1 -1
- data/spec/rails-app/Gemfile.lock +4 -0
- data/spec/rails-app/app/assets/javascripts/devise_authy.js +5 -0
- data/spec/rails-app/app/assets/stylesheets/devise_authy.css +4 -4
- data/spec/rails-app/app/views/devise/devise_authy/enable_authy.html.erb +2 -3
- data/spec/rails-app/app/views/devise/devise_authy/verify_authy.html.erb +10 -2
- data/spec/rails-app/app/views/layouts/application.html.erb +0 -1
- data/spec/rails-app/config/locales/devise.authy.en.yml +6 -1
- metadata +29 -29
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OWMwMGEzZDEzMmE1YjVlZTM5MDEzYjE4NmRhNDJhN2M3M2E5OTJkOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ODNmNmI0Yjc1ZjgzNTRjYmM3MDE2MDNkNmZiNTFhMTg0ZjFhYTI3ZQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
N2JlNjM5MzcyYmJmZmQ5MzM2OTA2YTQwMTVkNGVmNjU4NGFhN2MyNWZhYzMx
|
10
|
+
Y2M4ZTYxZDZhOWM1MmE2NTM0ZmYwMTcwNGUzYjhmOTI3ZWE1MDZkZmUwODRl
|
11
|
+
Y2MxNWQ3ZGM0MDBkZWYwNDNhYzA5NmVhODk1MzlhODdlMzBjNWE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTg1MWYxMTMyYTI0YmZkYjJkNjU0NWY2YmZmMTJmNjFmZmUwYTlmOGZhZmYy
|
14
|
+
NDBjNmI2ZDI4MzIwNWIyMTA1ODU0NmQyYmQ2NGE0MDc5ZDg5ZDFjOWZiOTk2
|
15
|
+
ZDdiZGYxN2RiODJhMGJjMmUxMTc2OTc2M2UyOWI2NDhiZTNlMmE=
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -99,6 +99,10 @@ class MyCustomModule::DeviseAuthyController < Devise::DeviseAuthyController
|
|
99
99
|
my_own_path
|
100
100
|
end
|
101
101
|
|
102
|
+
def after_authy_disabled_path_for(resource)
|
103
|
+
my_own_path
|
104
|
+
end
|
105
|
+
|
102
106
|
def invalid_resource_path
|
103
107
|
my_own_path
|
104
108
|
end
|
@@ -118,6 +122,18 @@ The install generator also copy a `Devise Authy` i18n file which you can find at
|
|
118
122
|
|
119
123
|
config/locales/devise.authy.en.yml
|
120
124
|
|
125
|
+
## Session variables
|
126
|
+
|
127
|
+
If you want to know if the user is signed in using Two-Factor authentication,
|
128
|
+
you can use the following session variable:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
session["#{resource_name}_authy_token_checked"]
|
132
|
+
|
133
|
+
# Eg.
|
134
|
+
session["user_authy_token_checked"]
|
135
|
+
```
|
136
|
+
|
121
137
|
|
122
138
|
## Running Tests
|
123
139
|
|
@@ -135,5 +151,5 @@ $ bundle exec rspec spec/
|
|
135
151
|
|
136
152
|
## Copyright
|
137
153
|
|
138
|
-
Copyright (c)
|
154
|
+
Copyright (c) 2012-2020 Authy Inc. See LICENSE.txt for
|
139
155
|
further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
@@ -3,5 +3,10 @@ $(document).ready(function() {
|
|
3
3
|
$('a#authy-request-sms-link').bind('ajax:success', function(evt, data, status, xhr) {
|
4
4
|
alert(data.message);
|
5
5
|
});
|
6
|
+
|
7
|
+
$('a#authy-request-phone-call-link').unbind('ajax:success');
|
8
|
+
$('a#authy-request-phone-call-link').bind('ajax:success', function(evt, data, status, xhr) {
|
9
|
+
alert(data.message);
|
10
|
+
});
|
6
11
|
});
|
7
12
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Devise::DeviseAuthyController < DeviseController
|
2
2
|
prepend_before_filter :find_resource, :only => [
|
3
|
-
:request_sms
|
3
|
+
:request_phone_call, :request_sms
|
4
4
|
]
|
5
5
|
prepend_before_filter :find_resource_and_require_password_checked, :only => [
|
6
6
|
:GET_verify_authy, :POST_verify_authy
|
@@ -28,6 +28,8 @@ class Devise::DeviseAuthyController < DeviseController
|
|
28
28
|
if token.ok?
|
29
29
|
@resource.update_attribute(:last_sign_in_with_authy, DateTime.now)
|
30
30
|
|
31
|
+
session["#{resource_name}_authy_token_checked"] = true
|
32
|
+
|
31
33
|
remember_device if params[:remember_device].to_i == 1
|
32
34
|
if session.delete("#{resource_name}_remember_me") == true && @resource.respond_to?(:remember_me=)
|
33
35
|
@resource.remember_me = true
|
@@ -87,7 +89,7 @@ class Devise::DeviseAuthyController < DeviseController
|
|
87
89
|
set_flash_message(:error, :not_disabled)
|
88
90
|
end
|
89
91
|
|
90
|
-
redirect_to
|
92
|
+
redirect_to after_authy_disabled_path_for(resource)
|
91
93
|
end
|
92
94
|
|
93
95
|
def GET_verify_authy_installation
|
@@ -103,14 +105,24 @@ class Devise::DeviseAuthyController < DeviseController
|
|
103
105
|
|
104
106
|
self.resource.authy_enabled = token.ok?
|
105
107
|
|
106
|
-
if
|
107
|
-
handle_invalid_token :verify_authy_installation, :not_enabled
|
108
|
-
else
|
108
|
+
if token.ok? && self.resource.save
|
109
109
|
set_flash_message(:notice, :enabled)
|
110
110
|
redirect_to after_authy_verified_path_for(resource)
|
111
|
+
else
|
112
|
+
handle_invalid_token :verify_authy_installation, :not_enabled
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
116
|
+
def request_phone_call
|
117
|
+
unless @resource
|
118
|
+
render :json => { :sent => false, :message => "User couldn't be found." }
|
119
|
+
return
|
120
|
+
end
|
121
|
+
|
122
|
+
response = Authy::API.request_phone_call(:id => @resource.authy_id, :force => true)
|
123
|
+
render :json => { :sent => response.ok?, :message => response.message }
|
124
|
+
end
|
125
|
+
|
114
126
|
def request_sms
|
115
127
|
if !@resource
|
116
128
|
render :json => {:sent => false, :message => "User couldn't be found."}
|
@@ -155,6 +167,10 @@ class Devise::DeviseAuthyController < DeviseController
|
|
155
167
|
after_authy_enabled_path_for(resource)
|
156
168
|
end
|
157
169
|
|
170
|
+
def after_authy_disabled_path_for(resource)
|
171
|
+
root_path
|
172
|
+
end
|
173
|
+
|
158
174
|
def invalid_resource_path
|
159
175
|
root_path
|
160
176
|
end
|
@@ -11,8 +11,11 @@
|
|
11
11
|
<span><%= I18n.t('remember_device', {:scope => 'devise'}) %></span>
|
12
12
|
</label>
|
13
13
|
|
14
|
-
|
14
|
+
<!-- Help tooltip -->
|
15
|
+
<!-- You need to configure a help message. -->
|
16
|
+
<!-- See documentation: https://github.com/authy/authy-form-helpers#help-tooltip -->
|
17
|
+
<!-- <%= link_to '?', '#', :id => 'authy-help' %> -->
|
18
|
+
|
15
19
|
<%= authy_request_sms_link %>
|
16
20
|
<%= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn' %>
|
17
21
|
<% end %>
|
18
|
-
|
@@ -8,7 +8,11 @@
|
|
8
8
|
%label
|
9
9
|
= check_box_tag :remember_device
|
10
10
|
%span= I18n.t('remember_device', {:scope => 'devise'})
|
11
|
-
|
11
|
+
|
12
|
+
/ Help Tooltip
|
13
|
+
/ You need to configure a help message.
|
14
|
+
/ See documentation: https://github.com/authy/authy-form-helpers#help-tooltip
|
15
|
+
/ = link_to '?', '#', :id => 'authy-help', :'data-message' => 'a message'
|
16
|
+
|
12
17
|
= authy_request_sms_link
|
13
18
|
= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn'
|
14
|
-
|
@@ -3,5 +3,10 @@ $(document).ready(function() {
|
|
3
3
|
$('a#authy-request-sms-link').bind('ajax:success', function(evt, data, status, xhr) {
|
4
4
|
alert(data.message);
|
5
5
|
});
|
6
|
+
|
7
|
+
$('a#authy-request-phone-call-link').unbind('ajax:success');
|
8
|
+
$('a#authy-request-phone-call-link').bind('ajax:success', function(evt, data, status, xhr) {
|
9
|
+
alert(data.message);
|
10
|
+
});
|
6
11
|
});
|
7
12
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
width: 350px;
|
5
5
|
}
|
6
6
|
|
7
|
-
legend {
|
7
|
+
.authy-form legend {
|
8
8
|
display: block;
|
9
9
|
width: 100%;
|
10
10
|
padding: 0;
|
@@ -15,9 +15,9 @@ legend {
|
|
15
15
|
border-bottom: 1px solid #E5E5E5;
|
16
16
|
}
|
17
17
|
|
18
|
-
label,
|
19
|
-
input,
|
20
|
-
button {
|
18
|
+
.authy-form label,
|
19
|
+
.authy-form input,
|
20
|
+
.authy-form button {
|
21
21
|
font-size: 14px;
|
22
22
|
font-weight: normal;
|
23
23
|
line-height: 20px;
|
@@ -11,8 +11,12 @@
|
|
11
11
|
<span><%= I18n.t('remember_device', {:scope => 'devise'}) %></span>
|
12
12
|
</label>
|
13
13
|
|
14
|
-
|
14
|
+
<!-- Help tooltip -->
|
15
|
+
<!-- You need to configure a help message. -->
|
16
|
+
<!-- See documentation: https://github.com/authy/authy-form-helpers#help-tooltip -->
|
17
|
+
<!-- <%= link_to '?', '#', :id => 'authy-help' %> -->
|
18
|
+
|
15
19
|
<%= authy_request_sms_link %>
|
20
|
+
<%= authy_request_phone_call_link %>
|
16
21
|
<%= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn' %>
|
17
22
|
<% end %>
|
18
|
-
|
@@ -1,6 +1,11 @@
|
|
1
1
|
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
2
|
# Many of these configuration options can be set straight in your model.
|
3
3
|
Devise.setup do |config|
|
4
|
+
|
5
|
+
# ==> Devise Authy Authentication Extension
|
6
|
+
# How long should the user's device be remembered for.
|
7
|
+
# config.authy_remember_device = 1.month
|
8
|
+
|
4
9
|
# ==> Mailer Configuration
|
5
10
|
# Configure the e-mail address which will be shown in Devise::Mailer,
|
6
11
|
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
@@ -229,9 +234,4 @@ Devise.setup do |config|
|
|
229
234
|
# When using omniauth, Devise cannot automatically set Omniauth path,
|
230
235
|
# so you need to do it manually. For the users scope, it would be:
|
231
236
|
# config.omniauth_path_prefix = "/my_engine/users/auth"
|
232
|
-
|
233
|
-
# ==> Devise Authy Authentication Extension
|
234
|
-
# How long should the user's device be remembered for.
|
235
|
-
config.authy_remember_device = 1.minute
|
236
|
-
|
237
237
|
end
|
@@ -5,8 +5,9 @@ en:
|
|
5
5
|
authy_register_title: 'Enable Two factor authentication'
|
6
6
|
enable_authy: 'Enable'
|
7
7
|
cellphone: 'Enter your cellphone'
|
8
|
-
country: 'Enter
|
8
|
+
country: 'Enter your country'
|
9
9
|
request_sms: 'Request SMS'
|
10
|
+
request_phone_call: 'Request phone call'
|
10
11
|
remember_device: 'Remember Device'
|
11
12
|
|
12
13
|
authy_verify_installation_title: "Verify your account"
|
@@ -16,6 +17,8 @@ en:
|
|
16
17
|
admin:
|
17
18
|
enabled: 'Two factor authentication was enabled'
|
18
19
|
not_enabled: 'Something went wrong while enabling two factor authentication'
|
20
|
+
disabled: 'Two factor authentication was disabled'
|
21
|
+
not_disabled: 'Something went wrong while disabling two factor authentication'
|
19
22
|
signed_in: 'Signed in with Authy successfully.'
|
20
23
|
already_enabled: "Two factor authentication is already enabled."
|
21
|
-
invalid_token: 'The entered token is invalid
|
24
|
+
invalid_token: 'The entered token is invalid'
|
data/config/locales/en.yml
CHANGED
@@ -5,8 +5,9 @@ en:
|
|
5
5
|
authy_register_title: 'Enable Two factor authentication'
|
6
6
|
enable_authy: 'Enable'
|
7
7
|
cellphone: 'Enter your cellphone'
|
8
|
-
country: 'Enter
|
8
|
+
country: 'Enter your country'
|
9
9
|
request_sms: 'Request SMS'
|
10
|
+
request_phone_call: 'Request phone call'
|
10
11
|
remember_device: 'Remember Device'
|
11
12
|
|
12
13
|
authy_verify_installation_title: "Verify your account"
|
data/devise-authy.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: devise-authy 1.
|
5
|
+
# stub: devise-authy 1.7.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "devise-authy"
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.7.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Authy Inc."]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2015-12-22"
|
15
15
|
s.description = "Authy plugin for Devise"
|
16
16
|
s.email = "support@authy.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -197,7 +197,7 @@ Gem::Specification.new do |s|
|
|
197
197
|
]
|
198
198
|
s.homepage = "https://github.com/authy/authy-devise"
|
199
199
|
s.licenses = ["MIT"]
|
200
|
-
s.rubygems_version = "2.4.
|
200
|
+
s.rubygems_version = "2.4.8"
|
201
201
|
s.summary = "Authy plugin for Devise"
|
202
202
|
|
203
203
|
if s.respond_to? :specification_version then
|
@@ -1,36 +1,61 @@
|
|
1
1
|
module DeviseAuthy
|
2
2
|
module Views
|
3
3
|
module Helpers
|
4
|
+
def authy_request_phone_call_link(opts = {})
|
5
|
+
opts = {
|
6
|
+
:id => "authy-request-phone-call-link",
|
7
|
+
:method => :post,
|
8
|
+
:remote => true
|
9
|
+
}.merge(opts)
|
4
10
|
|
5
|
-
def authy_request_sms_link
|
6
11
|
link_to(
|
7
|
-
I18n.t('
|
8
|
-
url_for([resource_name, :
|
12
|
+
I18n.t('request_phone_call', { :scope => 'devise' }),
|
13
|
+
url_for([resource_name, :request_phone_call]),
|
14
|
+
opts
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def authy_request_sms_link(opts = {})
|
19
|
+
opts = {
|
9
20
|
:id => "authy-request-sms-link",
|
10
21
|
:method => :post,
|
11
22
|
:remote => true
|
23
|
+
}.merge(opts)
|
24
|
+
|
25
|
+
link_to(
|
26
|
+
I18n.t('request_sms', {:scope => 'devise'}),
|
27
|
+
url_for([resource_name, :request_sms]),
|
28
|
+
opts
|
12
29
|
)
|
13
30
|
end
|
14
31
|
|
15
|
-
def verify_authy_form(&block)
|
16
|
-
|
32
|
+
def verify_authy_form(opts = {}, &block)
|
33
|
+
opts = default_opts.merge(:id => 'devise_authy').merge(opts)
|
34
|
+
form_tag([resource_name, :verify_authy], opts) do
|
17
35
|
buffer = hidden_field_tag(:"#{resource_name}_id", @resource.id)
|
18
36
|
buffer << capture(&block)
|
19
37
|
end
|
20
38
|
end
|
21
39
|
|
22
|
-
def enable_authy_form(&block)
|
23
|
-
|
40
|
+
def enable_authy_form(opts = {}, &block)
|
41
|
+
opts = default_opts.merge(opts)
|
42
|
+
form_tag([resource_name, :enable_authy], opts) do
|
24
43
|
capture(&block)
|
25
44
|
end
|
26
45
|
end
|
27
46
|
|
28
|
-
def verify_authy_installation_form(&block)
|
29
|
-
|
47
|
+
def verify_authy_installation_form(opts = {}, &block)
|
48
|
+
opts = default_opts.merge(opts)
|
49
|
+
form_tag([resource_name, :verify_authy_installation], opts) do
|
30
50
|
capture(&block)
|
31
51
|
end
|
32
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def default_opts
|
57
|
+
{ :class => 'authy-form', :method => :post }
|
58
|
+
end
|
33
59
|
end
|
34
60
|
end
|
35
61
|
end
|
36
|
-
|
data/lib/devise-authy/routes.rb
CHANGED
@@ -16,6 +16,7 @@ module ActionDispatch::Routing
|
|
16
16
|
|
17
17
|
|
18
18
|
match "/request-sms", :controller => controllers[:devise_authy], :action => :request_sms, :as => :request_sms, :via => :post
|
19
|
+
match "/request-phone-call", :controller => controllers[:devise_authy], :action => :request_phone_call, :as => :request_phone_call, :via => :post
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -13,7 +13,7 @@ module DeviseAuthy
|
|
13
13
|
inject_into_file "config/initializers/devise.rb", "\n" +
|
14
14
|
" # ==> Devise Authy Authentication Extension\n" +
|
15
15
|
" # How long should the user's device be remembered for.\n" +
|
16
|
-
" # config.authy_remember_device = 1.month\n\n", :
|
16
|
+
" # config.authy_remember_device = 1.month\n\n", :after => "Devise.setup do |config|\n"
|
17
17
|
end
|
18
18
|
|
19
19
|
def copy_locale
|
@@ -48,7 +48,6 @@ module DeviseAuthy
|
|
48
48
|
:content => %@
|
49
49
|
=javascript_include_tag "https://www.authy.com/form.authy.min.js"
|
50
50
|
=stylesheet_link_tag "https://www.authy.com/form.authy.min.css"
|
51
|
-
=javascript_include_tag "devise_authy.js"
|
52
51
|
@
|
53
52
|
},
|
54
53
|
:erb => {
|
@@ -56,12 +55,11 @@ module DeviseAuthy
|
|
56
55
|
:content => %@
|
57
56
|
<%=javascript_include_tag "https://www.authy.com/form.authy.min.js" %>
|
58
57
|
<%=stylesheet_link_tag "https://www.authy.com/form.authy.min.css" %>
|
59
|
-
<%=javascript_include_tag "devise_authy.js" %>
|
60
58
|
@
|
61
59
|
}
|
62
60
|
}.each do |extension, opts|
|
63
61
|
file_path = "app/views/layouts/application.html.#{extension}"
|
64
|
-
if File.exists?(file_path) && !File.read(file_path).include?("
|
62
|
+
if File.exists?(file_path) && !File.read(file_path).include?("form.authy.min.js")
|
65
63
|
inject_into_file(file_path, opts.delete(:content), opts)
|
66
64
|
end
|
67
65
|
end
|
@@ -5,7 +5,7 @@ describe Devise::DeviseAuthyController do
|
|
5
5
|
|
6
6
|
before :each do
|
7
7
|
request.env["devise.mapping"] = Devise.mappings[:user]
|
8
|
-
@user = create_user(:authy_id =>
|
8
|
+
@user = create_user(:authy_id => 2)
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "GET #verify_authy" do
|
@@ -40,6 +40,7 @@ describe Devise::DeviseAuthyController do
|
|
40
40
|
response.cookies["remember_device"].should be_nil
|
41
41
|
response.should redirect_to(root_url)
|
42
42
|
flash.now[:notice].should_not be_nil
|
43
|
+
session["user_authy_token_checked"].should be_true
|
43
44
|
end
|
44
45
|
|
45
46
|
it "Should set remember_device if selected" do
|
@@ -212,6 +213,9 @@ describe Devise::DeviseAuthyController do
|
|
212
213
|
post :POST_verify_authy_installation, :token => "0000000"
|
213
214
|
response.should redirect_to(root_url)
|
214
215
|
flash[:notice].should == 'Two factor authentication was enabled'
|
216
|
+
|
217
|
+
@user.reload
|
218
|
+
@user.authy_enabled.should be_true
|
215
219
|
end
|
216
220
|
|
217
221
|
it "should not enable authy for user" do
|
@@ -245,4 +249,23 @@ describe Devise::DeviseAuthyController do
|
|
245
249
|
body['message'].should == "User couldn't be found."
|
246
250
|
end
|
247
251
|
end
|
252
|
+
|
253
|
+
describe "POST #request_phone_call" do
|
254
|
+
it "Should send phone call if user is logged" do
|
255
|
+
sign_in @user
|
256
|
+
post :request_phone_call
|
257
|
+
response.content_type.should == 'application/json'
|
258
|
+
body = JSON.parse(response.body)
|
259
|
+
body['sent'].should be_true
|
260
|
+
body['message'].should == "Call started..."
|
261
|
+
end
|
262
|
+
|
263
|
+
it "Shoul not send phone call if user couldn't be found" do
|
264
|
+
post :request_phone_call
|
265
|
+
response.content_type.should == 'application/json'
|
266
|
+
body = JSON.parse(response.body)
|
267
|
+
body['sent'].should be_false
|
268
|
+
body['message'].should == "User couldn't be found."
|
269
|
+
end
|
270
|
+
end
|
248
271
|
end
|
data/spec/rails-app/Gemfile
CHANGED
data/spec/rails-app/Gemfile.lock
CHANGED
@@ -50,6 +50,9 @@ GEM
|
|
50
50
|
httpclient (2.3.3)
|
51
51
|
i18n (0.6.1)
|
52
52
|
journey (1.0.4)
|
53
|
+
jquery-rails (3.1.4)
|
54
|
+
railties (>= 3.0, < 5.0)
|
55
|
+
thor (>= 0.14, < 2.0)
|
53
56
|
json (1.7.7)
|
54
57
|
mail (2.5.3)
|
55
58
|
i18n (>= 0.4.0)
|
@@ -106,6 +109,7 @@ DEPENDENCIES
|
|
106
109
|
authy
|
107
110
|
devise
|
108
111
|
devise-authy!
|
112
|
+
jquery-rails
|
109
113
|
rails (~> 3.2.6)
|
110
114
|
rake
|
111
115
|
sqlite3
|
@@ -3,5 +3,10 @@ $(document).ready(function() {
|
|
3
3
|
$('a#authy-request-sms-link').bind('ajax:success', function(evt, data, status, xhr) {
|
4
4
|
alert(data.message);
|
5
5
|
});
|
6
|
+
|
7
|
+
$('a#authy-request-phone-call-link').unbind('ajax:success');
|
8
|
+
$('a#authy-request-phone-call-link').bind('ajax:success', function(evt, data, status, xhr) {
|
9
|
+
alert(data.message);
|
10
|
+
});
|
6
11
|
});
|
7
12
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
width: 350px;
|
5
5
|
}
|
6
6
|
|
7
|
-
legend {
|
7
|
+
.authy-form legend {
|
8
8
|
display: block;
|
9
9
|
width: 100%;
|
10
10
|
padding: 0;
|
@@ -15,9 +15,9 @@ legend {
|
|
15
15
|
border-bottom: 1px solid #E5E5E5;
|
16
16
|
}
|
17
17
|
|
18
|
-
label,
|
19
|
-
input,
|
20
|
-
button {
|
18
|
+
.authy-form label,
|
19
|
+
.authy-form input,
|
20
|
+
.authy-form button {
|
21
21
|
font-size: 14px;
|
22
22
|
font-weight: normal;
|
23
23
|
line-height: 20px;
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
<%= enable_authy_form do %>
|
4
4
|
<%= text_field_tag :country_code, '', :autocomplete => :off, :placeholder => I18n.t('devise.country'), :id => "authy-countries"%>
|
5
|
-
<p><%= submit_tag I18n.t('enable_authy', {:scope => 'devise'}) %></p>
|
6
5
|
<%= text_field_tag :cellphone, '', :autocomplete => :off, :placeholder => I18n.t('devise.cellphone'), :id => "authy-cellphone"%>
|
7
|
-
|
8
|
-
|
6
|
+
<p><%= submit_tag I18n.t('enable_authy', {:scope => 'devise'}) %></p>
|
7
|
+
<% end %>
|
@@ -6,8 +6,16 @@
|
|
6
6
|
<legend><%= I18n.t('submit_token_title', {:scope => 'devise'}) %></legend>
|
7
7
|
<%= label_tag :token %>
|
8
8
|
<%= text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token' %>
|
9
|
-
|
9
|
+
<label>
|
10
|
+
<%= check_box_tag :remember_device %>
|
11
|
+
<span><%= I18n.t('remember_device', {:scope => 'devise'}) %></span>
|
12
|
+
</label>
|
13
|
+
|
14
|
+
<!-- Help tooltip -->
|
15
|
+
<!-- You need to configure a help message. -->
|
16
|
+
<!-- See documentation: https://github.com/authy/authy-form-helpers#help-tooltip -->
|
17
|
+
<!-- <%= link_to '?', '#', :id => 'authy-help' %> -->
|
18
|
+
|
10
19
|
<%= authy_request_sms_link %>
|
11
20
|
<%= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn' %>
|
12
21
|
<% end %>
|
13
|
-
|
@@ -5,8 +5,10 @@ en:
|
|
5
5
|
authy_register_title: 'Enable Two factor authentication'
|
6
6
|
enable_authy: 'Enable'
|
7
7
|
cellphone: 'Enter your cellphone'
|
8
|
-
country: 'Enter
|
8
|
+
country: 'Enter your country'
|
9
9
|
request_sms: 'Request SMS'
|
10
|
+
request_phone_call: 'Request phone call'
|
11
|
+
remember_device: 'Remember Device'
|
10
12
|
|
11
13
|
authy_verify_installation_title: "Verify your account"
|
12
14
|
enable_my_account: 'Enable my account'
|
@@ -15,5 +17,8 @@ en:
|
|
15
17
|
user:
|
16
18
|
enabled: 'Two factor authentication was enabled'
|
17
19
|
not_enabled: 'Something went wrong while enabling two factor authentication'
|
20
|
+
disabled: 'Two factor authentication was disabled'
|
21
|
+
not_disabled: 'Something went wrong while disabling two factor authentication'
|
18
22
|
signed_in: 'Signed in with Authy successfully.'
|
23
|
+
already_enabled: "Two factor authentication is already enabled."
|
19
24
|
invalid_token: 'The entered token is invalid'
|
metadata
CHANGED
@@ -1,167 +1,167 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-authy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Authy Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: authy
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdoc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ! '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ! '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: jeweler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ! '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 2.0.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ! '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.0.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ! '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: sass-rails
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ! '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ! '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: jquery-rails
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ! '>='
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ! '>='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: pry
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ! '>='
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ! '>='
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
description: Authy plugin for Devise
|
@@ -172,8 +172,8 @@ extra_rdoc_files:
|
|
172
172
|
- LICENSE.txt
|
173
173
|
- README.md
|
174
174
|
files:
|
175
|
-
-
|
176
|
-
-
|
175
|
+
- .document
|
176
|
+
- .rspec
|
177
177
|
- Gemfile
|
178
178
|
- Gemfile.lock
|
179
179
|
- LICENSE.txt
|
@@ -357,17 +357,17 @@ require_paths:
|
|
357
357
|
- lib
|
358
358
|
required_ruby_version: !ruby/object:Gem::Requirement
|
359
359
|
requirements:
|
360
|
-
- -
|
360
|
+
- - ! '>='
|
361
361
|
- !ruby/object:Gem::Version
|
362
362
|
version: '0'
|
363
363
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
364
364
|
requirements:
|
365
|
-
- -
|
365
|
+
- - ! '>='
|
366
366
|
- !ruby/object:Gem::Version
|
367
367
|
version: '0'
|
368
368
|
requirements: []
|
369
369
|
rubyforge_project:
|
370
|
-
rubygems_version: 2.
|
370
|
+
rubygems_version: 2.4.8
|
371
371
|
signing_key:
|
372
372
|
specification_version: 4
|
373
373
|
summary: Authy plugin for Devise
|