devise-authy 1.7.0 → 2.3.1
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 +5 -13
- data/.github/workflows/build.yml +32 -0
- data/.gitignore +45 -0
- data/.rspec +1 -0
- data/Appraisals +22 -0
- data/CHANGELOG.md +152 -0
- data/Gemfile +2 -23
- data/LICENSE.txt +1 -1
- data/README.md +147 -36
- data/Rakefile +1 -14
- data/app/controllers/devise/devise_authy_controller.rb +90 -30
- data/app/controllers/devise_authy/passwords_controller.rb +18 -0
- data/app/views/devise/enable_authy.html.erb +2 -2
- data/app/views/devise/enable_authy.html.haml +2 -2
- data/app/views/devise/verify_authy.html.erb +23 -6
- data/app/views/devise/verify_authy.html.haml +21 -6
- data/app/views/devise/verify_authy_installation.html.erb +14 -6
- data/app/views/devise/verify_authy_installation.html.haml +12 -4
- data/config/locales/en.yml +8 -4
- data/config.ru +9 -0
- data/devise-authy.gemspec +44 -239
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_5_2.gemfile +14 -0
- data/gemfiles/rails_6.gemfile +15 -0
- data/lib/devise-authy/controllers/helpers.rb +31 -12
- data/lib/devise-authy/controllers/view_helpers.rb +13 -7
- data/lib/devise-authy/mapping.rb +10 -7
- data/lib/devise-authy/models/authy_authenticatable.rb +2 -2
- data/lib/devise-authy/rails.rb +1 -1
- data/lib/devise-authy/routes.rb +3 -2
- data/lib/devise-authy/version.rb +5 -0
- data/lib/devise-authy.rb +8 -1
- data/lib/generators/active_record/devise_authy_generator.rb +11 -1
- data/lib/generators/active_record/templates/migration.rb +1 -1
- data/lib/generators/devise_authy/devise_authy_generator.rb +8 -8
- data/lib/generators/devise_authy/install_generator.rb +19 -5
- metadata +173 -205
- data/Gemfile.lock +0 -194
- data/VERSION +0 -1
- data/authy-devise-demo/.gitignore +0 -15
- data/authy-devise-demo/Gemfile +0 -40
- data/authy-devise-demo/Gemfile.lock +0 -141
- data/authy-devise-demo/README.md +0 -64
- data/authy-devise-demo/Rakefile +0 -7
- data/authy-devise-demo/app/assets/images/rails.png +0 -0
- data/authy-devise-demo/app/assets/javascripts/application.js +0 -15
- data/authy-devise-demo/app/assets/javascripts/devise_authy.js +0 -12
- data/authy-devise-demo/app/assets/javascripts/welcome.js.coffee +0 -3
- data/authy-devise-demo/app/assets/stylesheets/application.css +0 -13
- data/authy-devise-demo/app/assets/stylesheets/devise_authy.css +0 -26
- data/authy-devise-demo/app/assets/stylesheets/welcome.css.scss +0 -3
- data/authy-devise-demo/app/controllers/application_controller.rb +0 -3
- data/authy-devise-demo/app/controllers/welcome_controller.rb +0 -15
- data/authy-devise-demo/app/helpers/application_helper.rb +0 -2
- data/authy-devise-demo/app/helpers/welcome_helper.rb +0 -2
- data/authy-devise-demo/app/mailers/.gitkeep +0 -0
- data/authy-devise-demo/app/models/.gitkeep +0 -0
- data/authy-devise-demo/app/models/admin.rb +0 -10
- data/authy-devise-demo/app/models/user.rb +0 -10
- data/authy-devise-demo/app/views/devise/devise_authy/enable_authy.html.erb +0 -7
- data/authy-devise-demo/app/views/devise/devise_authy/verify_authy.html.erb +0 -22
- data/authy-devise-demo/app/views/devise/devise_authy/verify_authy_installation.html.erb +0 -10
- data/authy-devise-demo/app/views/layouts/application.html.erb +0 -28
- data/authy-devise-demo/app/views/welcome/admin_page.html.erb +0 -12
- data/authy-devise-demo/app/views/welcome/index.html.erb +0 -5
- data/authy-devise-demo/app/views/welcome/user_page.html.erb +0 -5
- data/authy-devise-demo/config/application.rb +0 -62
- data/authy-devise-demo/config/boot.rb +0 -6
- data/authy-devise-demo/config/database.yml +0 -25
- data/authy-devise-demo/config/environment.rb +0 -5
- data/authy-devise-demo/config/environments/development.rb +0 -39
- data/authy-devise-demo/config/environments/production.rb +0 -67
- data/authy-devise-demo/config/environments/test.rb +0 -37
- data/authy-devise-demo/config/initializers/authy.rb +0 -1
- data/authy-devise-demo/config/initializers/backtrace_silencers.rb +0 -7
- data/authy-devise-demo/config/initializers/devise.rb +0 -237
- data/authy-devise-demo/config/initializers/inflections.rb +0 -15
- data/authy-devise-demo/config/initializers/mime_types.rb +0 -5
- data/authy-devise-demo/config/initializers/secret_token.rb +0 -7
- data/authy-devise-demo/config/initializers/session_store.rb +0 -8
- data/authy-devise-demo/config/initializers/wrap_parameters.rb +0 -14
- data/authy-devise-demo/config/locales/devise.authy.en.yml +0 -24
- data/authy-devise-demo/config/locales/devise.en.yml +0 -58
- data/authy-devise-demo/config/locales/en.yml +0 -5
- data/authy-devise-demo/config/routes.rb +0 -65
- data/authy-devise-demo/config.ru +0 -4
- data/authy-devise-demo/db/migrate/20130409234357_devise_create_users.rb +0 -46
- data/authy-devise-demo/db/migrate/20141202000744_devise_create_admins.rb +0 -46
- data/authy-devise-demo/db/migrate/20141202004246_devise_authy_add_to_admins.rb +0 -21
- data/authy-devise-demo/db/schema.rb +0 -62
- data/authy-devise-demo/db/seeds.rb +0 -7
- data/authy-devise-demo/lib/assets/.gitkeep +0 -0
- data/authy-devise-demo/lib/tasks/.gitkeep +0 -0
- data/authy-devise-demo/log/.gitkeep +0 -0
- data/authy-devise-demo/public/404.html +0 -26
- data/authy-devise-demo/public/422.html +0 -26
- data/authy-devise-demo/public/500.html +0 -25
- data/authy-devise-demo/public/favicon.ico +0 -0
- data/authy-devise-demo/public/robots.txt +0 -5
- data/authy-devise-demo/script/rails +0 -6
- data/authy-devise-demo/test/fixtures/.gitkeep +0 -0
- data/authy-devise-demo/test/fixtures/users.yml +0 -11
- data/authy-devise-demo/test/functional/.gitkeep +0 -0
- data/authy-devise-demo/test/functional/welcome_controller_test.rb +0 -9
- data/authy-devise-demo/test/integration/.gitkeep +0 -0
- data/authy-devise-demo/test/performance/browsing_test.rb +0 -12
- data/authy-devise-demo/test/test_helper.rb +0 -13
- data/authy-devise-demo/test/unit/.gitkeep +0 -0
- data/authy-devise-demo/test/unit/helpers/welcome_helper_test.rb +0 -4
- data/authy-devise-demo/test/unit/user_test.rb +0 -7
- data/authy-devise-demo/vendor/assets/javascripts/.gitkeep +0 -0
- data/authy-devise-demo/vendor/assets/stylesheets/.gitkeep +0 -0
- data/authy-devise-demo/vendor/plugins/.gitkeep +0 -0
- data/spec/controllers/devise_authy_controller_spec.rb +0 -271
- data/spec/controllers/passwords_controller_spec.rb +0 -48
- data/spec/features/authy_authenticatable_spec.rb +0 -90
- data/spec/features/authy_lockable_spec.rb +0 -70
- data/spec/generators_spec.rb +0 -30
- data/spec/models/authy_authenticatable_spec.rb +0 -17
- data/spec/models/authy_lockable_spec.rb +0 -81
- data/spec/orm/active_record.rb +0 -4
- data/spec/rails-app/Gemfile +0 -9
- data/spec/rails-app/Gemfile.lock +0 -115
- data/spec/rails-app/Rakefile +0 -7
- data/spec/rails-app/app/assets/images/rails.png +0 -0
- data/spec/rails-app/app/assets/javascripts/application.js +0 -15
- data/spec/rails-app/app/assets/javascripts/devise_authy.js +0 -12
- data/spec/rails-app/app/assets/javascripts/welcome.js +0 -2
- data/spec/rails-app/app/assets/stylesheets/application.css +0 -13
- data/spec/rails-app/app/assets/stylesheets/devise_authy.css +0 -26
- data/spec/rails-app/app/assets/stylesheets/welcome.css.scss +0 -3
- data/spec/rails-app/app/controllers/application_controller.rb +0 -3
- data/spec/rails-app/app/controllers/welcome_controller.rb +0 -13
- data/spec/rails-app/app/helpers/application_helper.rb +0 -2
- data/spec/rails-app/app/helpers/welcome_helper.rb +0 -2
- data/spec/rails-app/app/mailers/.gitkeep +0 -0
- data/spec/rails-app/app/models/.gitkeep +0 -0
- data/spec/rails-app/app/models/lockable_user.rb +0 -7
- data/spec/rails-app/app/models/user.rb +0 -11
- data/spec/rails-app/app/views/devise/devise_authy/enable_authy.html.erb +0 -7
- data/spec/rails-app/app/views/devise/devise_authy/verify_authy.html.erb +0 -21
- data/spec/rails-app/app/views/devise/devise_authy/verify_authy_installation.html.erb +0 -10
- data/spec/rails-app/app/views/layouts/application.html.erb +0 -28
- data/spec/rails-app/app/views/welcome/index.html.erb +0 -5
- data/spec/rails-app/config/application.rb +0 -49
- data/spec/rails-app/config/boot.rb +0 -6
- data/spec/rails-app/config/database.yml +0 -25
- data/spec/rails-app/config/environment.rb +0 -5
- data/spec/rails-app/config/environments/development.rb +0 -39
- data/spec/rails-app/config/environments/production.rb +0 -67
- data/spec/rails-app/config/environments/test.rb +0 -39
- data/spec/rails-app/config/initializers/authy.rb +0 -2
- data/spec/rails-app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails-app/config/initializers/devise.rb +0 -245
- data/spec/rails-app/config/initializers/inflections.rb +0 -15
- data/spec/rails-app/config/initializers/mime_types.rb +0 -5
- data/spec/rails-app/config/initializers/secret_token.rb +0 -7
- data/spec/rails-app/config/initializers/session_store.rb +0 -8
- data/spec/rails-app/config/initializers/wrap_parameters.rb +0 -14
- data/spec/rails-app/config/locales/devise.authy.en.yml +0 -24
- data/spec/rails-app/config/locales/devise.en.yml +0 -59
- data/spec/rails-app/config/locales/en.yml +0 -5
- data/spec/rails-app/config/routes.rb +0 -8
- data/spec/rails-app/config.ru +0 -4
- data/spec/rails-app/db/development.sqlite3 +0 -0
- data/spec/rails-app/db/migrate/20130419164907_devise_create_users.rb +0 -46
- data/spec/rails-app/db/migrate/20130419164936_devise_authy_add_to_users.rb +0 -18
- data/spec/rails-app/db/schema.rb +0 -41
- data/spec/rails-app/db/seeds.rb +0 -7
- data/spec/rails-app/lib/assets/.gitkeep +0 -0
- data/spec/rails-app/lib/tasks/.gitkeep +0 -0
- data/spec/rails-app/public/404.html +0 -26
- data/spec/rails-app/public/422.html +0 -26
- data/spec/rails-app/public/500.html +0 -25
- data/spec/rails-app/public/favicon.ico +0 -0
- data/spec/rails-app/public/robots.txt +0 -5
- data/spec/rails-app/script/rails +0 -6
- data/spec/routing/routes_spec.rb +0 -31
- data/spec/spec_helper.rb +0 -29
- data/spec/support/helpers.rb +0 -78
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
class Devise::DeviseAuthyController < DeviseController
|
|
2
|
-
|
|
2
|
+
prepend_before_action :find_resource, :only => [
|
|
3
3
|
:request_phone_call, :request_sms
|
|
4
4
|
]
|
|
5
|
-
|
|
6
|
-
:GET_verify_authy, :POST_verify_authy
|
|
5
|
+
prepend_before_action :find_resource_and_require_password_checked, :only => [
|
|
6
|
+
:GET_verify_authy, :POST_verify_authy, :GET_authy_onetouch_status
|
|
7
7
|
]
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
:GET_verify_authy_installation, :POST_verify_authy_installation
|
|
11
|
-
|
|
8
|
+
|
|
9
|
+
prepend_before_action :check_resource_has_authy_id, :only => [
|
|
10
|
+
:GET_verify_authy_installation, :POST_verify_authy_installation
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
prepend_before_action :check_resource_not_authy_enabled, :only => [
|
|
14
|
+
:GET_verify_authy_installation, :POST_verify_authy_installation
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
prepend_before_action :authenticate_scope!, :only => [
|
|
18
|
+
:GET_enable_authy, :POST_enable_authy, :GET_verify_authy_installation,
|
|
19
|
+
:POST_verify_authy_installation, :POST_disable_authy
|
|
12
20
|
]
|
|
21
|
+
|
|
13
22
|
include Devise::Controllers::Helpers
|
|
14
23
|
|
|
15
24
|
def GET_verify_authy
|
|
16
|
-
|
|
25
|
+
if resource_class.authy_enable_onetouch
|
|
26
|
+
approval_request = send_one_touch_request(@resource.authy_id)['approval_request']
|
|
27
|
+
@onetouch_uuid = approval_request['uuid'] if approval_request.present?
|
|
28
|
+
end
|
|
17
29
|
render :verify_authy
|
|
18
30
|
end
|
|
19
31
|
|
|
@@ -26,17 +38,9 @@ class Devise::DeviseAuthyController < DeviseController
|
|
|
26
38
|
})
|
|
27
39
|
|
|
28
40
|
if token.ok?
|
|
29
|
-
@resource.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
remember_device if params[:remember_device].to_i == 1
|
|
34
|
-
if session.delete("#{resource_name}_remember_me") == true && @resource.respond_to?(:remember_me=)
|
|
35
|
-
@resource.remember_me = true
|
|
36
|
-
end
|
|
37
|
-
sign_in(resource_name, @resource)
|
|
38
|
-
|
|
39
|
-
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
|
41
|
+
remember_device(@resource.id) if params[:remember_device].to_i == 1
|
|
42
|
+
remember_user
|
|
43
|
+
record_authy_authentication
|
|
40
44
|
respond_with resource, :location => after_sign_in_path_for(@resource)
|
|
41
45
|
else
|
|
42
46
|
handle_invalid_token :verify_authy, :invalid_token
|
|
@@ -63,13 +67,11 @@ class Devise::DeviseAuthyController < DeviseController
|
|
|
63
67
|
if @authy_user.ok?
|
|
64
68
|
resource.authy_id = @authy_user.id
|
|
65
69
|
if resource.save
|
|
66
|
-
|
|
70
|
+
redirect_to [resource_name, :verify_authy_installation] and return
|
|
67
71
|
else
|
|
68
72
|
set_flash_message(:error, :not_enabled)
|
|
69
73
|
redirect_to after_authy_enabled_path_for(resource) and return
|
|
70
74
|
end
|
|
71
|
-
|
|
72
|
-
redirect_to [resource_name, :verify_authy_installation]
|
|
73
75
|
else
|
|
74
76
|
set_flash_message(:error, :not_enabled)
|
|
75
77
|
render :enable_authy
|
|
@@ -78,21 +80,39 @@ class Devise::DeviseAuthyController < DeviseController
|
|
|
78
80
|
|
|
79
81
|
# Disable 2FA
|
|
80
82
|
def POST_disable_authy
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
authy_id = resource.authy_id
|
|
84
|
+
resource.assign_attributes(:authy_enabled => false, :authy_id => nil)
|
|
85
|
+
resource.save(:validate => false)
|
|
86
|
+
|
|
87
|
+
other_resource = resource.class.find_by(:authy_id => authy_id)
|
|
88
|
+
if other_resource
|
|
89
|
+
# If another resource has the same authy_id, do not delete the user from
|
|
90
|
+
# the API.
|
|
91
|
+
forget_device
|
|
87
92
|
set_flash_message(:notice, :disabled)
|
|
88
93
|
else
|
|
89
|
-
|
|
94
|
+
response = Authy::API.delete_user(:id => authy_id)
|
|
95
|
+
if response.ok?
|
|
96
|
+
forget_device
|
|
97
|
+
set_flash_message(:notice, :disabled)
|
|
98
|
+
else
|
|
99
|
+
# If deleting the user from the API fails, set everything back to what
|
|
100
|
+
# it was before.
|
|
101
|
+
# I'm not sure this is a good idea, but it was existing behaviour.
|
|
102
|
+
# Could be changed in a major version bump.
|
|
103
|
+
resource.assign_attributes(:authy_enabled => true, :authy_id => authy_id)
|
|
104
|
+
resource.save(:validate => false)
|
|
105
|
+
set_flash_message(:error, :not_disabled)
|
|
106
|
+
end
|
|
90
107
|
end
|
|
91
|
-
|
|
92
108
|
redirect_to after_authy_disabled_path_for(resource)
|
|
93
109
|
end
|
|
94
110
|
|
|
95
111
|
def GET_verify_authy_installation
|
|
112
|
+
if resource_class.authy_enable_qr_code
|
|
113
|
+
response = Authy::API.request_qr_code(id: resource.authy_id)
|
|
114
|
+
@authy_qr_code = response.qr_code
|
|
115
|
+
end
|
|
96
116
|
render :verify_authy_installation
|
|
97
117
|
end
|
|
98
118
|
|
|
@@ -106,13 +126,37 @@ class Devise::DeviseAuthyController < DeviseController
|
|
|
106
126
|
self.resource.authy_enabled = token.ok?
|
|
107
127
|
|
|
108
128
|
if token.ok? && self.resource.save
|
|
129
|
+
remember_device(@resource.id) if params[:remember_device].to_i == 1
|
|
130
|
+
record_authy_authentication
|
|
109
131
|
set_flash_message(:notice, :enabled)
|
|
110
132
|
redirect_to after_authy_verified_path_for(resource)
|
|
111
133
|
else
|
|
134
|
+
if resource_class.authy_enable_qr_code
|
|
135
|
+
response = Authy::API.request_qr_code(id: resource.authy_id)
|
|
136
|
+
@authy_qr_code = response.qr_code
|
|
137
|
+
end
|
|
112
138
|
handle_invalid_token :verify_authy_installation, :not_enabled
|
|
113
139
|
end
|
|
114
140
|
end
|
|
115
141
|
|
|
142
|
+
def GET_authy_onetouch_status
|
|
143
|
+
response = Authy::OneTouch.approval_request_status(:uuid => params[:onetouch_uuid])
|
|
144
|
+
status = response.dig('approval_request', 'status')
|
|
145
|
+
case status
|
|
146
|
+
when 'pending'
|
|
147
|
+
head 202
|
|
148
|
+
when 'approved'
|
|
149
|
+
remember_device(@resource.id) if params[:remember_device].to_i == 1
|
|
150
|
+
remember_user
|
|
151
|
+
record_authy_authentication
|
|
152
|
+
render json: { redirect: after_sign_in_path_for(@resource) }
|
|
153
|
+
when 'denied'
|
|
154
|
+
head :unauthorized
|
|
155
|
+
else
|
|
156
|
+
head :internal_server_error
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
116
160
|
def request_phone_call
|
|
117
161
|
unless @resource
|
|
118
162
|
render :json => { :sent => false, :message => "User couldn't be found." }
|
|
@@ -157,6 +201,16 @@ class Devise::DeviseAuthyController < DeviseController
|
|
|
157
201
|
end
|
|
158
202
|
end
|
|
159
203
|
|
|
204
|
+
def check_resource_has_authy_id
|
|
205
|
+
redirect_to [resource_name, :enable_authy] if !resource.authy_id
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def check_resource_not_authy_enabled
|
|
209
|
+
if resource.authy_id && resource.authy_enabled
|
|
210
|
+
redirect_to after_authy_verified_path_for(resource)
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
160
214
|
protected
|
|
161
215
|
|
|
162
216
|
def after_authy_enabled_path_for(resource)
|
|
@@ -187,4 +241,10 @@ class Devise::DeviseAuthyController < DeviseController
|
|
|
187
241
|
def after_account_is_locked
|
|
188
242
|
sign_out_and_redirect @resource
|
|
189
243
|
end
|
|
244
|
+
|
|
245
|
+
def remember_user
|
|
246
|
+
if session.delete("#{resource_name}_remember_me") == true && @resource.respond_to?(:remember_me=)
|
|
247
|
+
@resource.remember_me = true
|
|
248
|
+
end
|
|
249
|
+
end
|
|
190
250
|
end
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
class DeviseAuthy::PasswordsController < Devise::PasswordsController
|
|
2
|
+
##
|
|
3
|
+
# In the passwords controller a user can update their password using a
|
|
4
|
+
# recovery token. If `Devise.sign_in_after_reset_password` is `true` then the
|
|
5
|
+
# user is signed in immediately with the
|
|
6
|
+
# `Devise::Controllers::SignInOut#sign_in` method. However, if the user has
|
|
7
|
+
# 2FA enabled they should enter their second factor before they are signed in.
|
|
8
|
+
#
|
|
9
|
+
# This method overrides `Devise::Controllers::SignInOut#sign_in` but only
|
|
10
|
+
# within the `Devise::PasswordsController`. If the user needs to verify 2FA
|
|
11
|
+
# then `sign_in` returns `true`. This short circuits the method before it can
|
|
12
|
+
# call `warden.set_user` and log the user in.
|
|
13
|
+
#
|
|
14
|
+
# The user is redirected to `after_resetting_password_path_for(user)` at which
|
|
15
|
+
# point, since the user is not logged in, redirects again to sign in.
|
|
16
|
+
#
|
|
17
|
+
# This doesn't retain the expected behaviour of
|
|
18
|
+
# `Devise.sign_in_after_reset_password`, but is forgivable because this
|
|
19
|
+
# shouldn't be an avenue to bypass 2FA.
|
|
2
20
|
def sign_in(resource_or_scope, *args)
|
|
3
21
|
resource = args.last || resource_or_scope
|
|
4
22
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<h2><%= I18n.t('authy_register_title',
|
|
1
|
+
<h2><%= I18n.t('authy_register_title', scope: 'devise') %></h2>
|
|
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
5
|
<%= text_field_tag :cellphone, '', :autocomplete => :off, :placeholder => I18n.t('devise.cellphone'), :id => "authy-cellphone"%>
|
|
6
|
-
<p><%= submit_tag I18n.t('enable_authy',
|
|
6
|
+
<p><%= submit_tag I18n.t('enable_authy', scope: 'devise') %></p>
|
|
7
7
|
<% end %>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
%h2= I18n.t('authy_register_title',
|
|
1
|
+
%h2= I18n.t('authy_register_title', scope: 'devise')
|
|
2
2
|
= enable_authy_form do
|
|
3
3
|
= text_field_tag :country_code, '', :autocomplete => :off, :placeholder => I18n.t('devise.country'), :id => "authy-countries"
|
|
4
4
|
= text_field_tag :cellphone, '', :autocomplete => :off, :placeholder => I18n.t('devise.cellphone'), :id => "authy-cellphone"
|
|
5
|
-
%p= submit_tag I18n.t('enable_authy',
|
|
5
|
+
%p= submit_tag I18n.t('enable_authy', scope: 'devise')
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<h2>
|
|
2
|
-
<%= I18n.t('
|
|
2
|
+
<%= I18n.t('submit_token_title', scope: 'devise') %>
|
|
3
3
|
</h2>
|
|
4
4
|
|
|
5
5
|
<%= verify_authy_form do %>
|
|
6
|
-
<legend><%= I18n.t('submit_token_title',
|
|
7
|
-
<%= label_tag
|
|
8
|
-
<%= text_field_tag :token, "", :autocomplete => :
|
|
6
|
+
<legend><%= I18n.t('submit_token_title', scope: 'devise') %></legend>
|
|
7
|
+
<%= label_tag 'authy-token' %>
|
|
8
|
+
<%= text_field_tag :token, "", :autocomplete => "one-time-code", :inputmode => "numeric", :pattern => "[0-9]*", :id => 'authy-token' %>
|
|
9
9
|
<label>
|
|
10
10
|
<%= check_box_tag :remember_device %>
|
|
11
|
-
<span><%= I18n.t('remember_device',
|
|
11
|
+
<span><%= I18n.t('remember_device', scope: 'devise') %></span>
|
|
12
12
|
</label>
|
|
13
13
|
|
|
14
14
|
<!-- Help tooltip -->
|
|
@@ -17,5 +17,22 @@
|
|
|
17
17
|
<!-- <%= link_to '?', '#', :id => 'authy-help' %> -->
|
|
18
18
|
|
|
19
19
|
<%= authy_request_sms_link %>
|
|
20
|
-
<%= submit_tag I18n.t('submit_token',
|
|
20
|
+
<%= submit_tag I18n.t('submit_token', scope: 'devise'), :class => 'btn' %>
|
|
21
|
+
<% end %>
|
|
22
|
+
|
|
23
|
+
<% if @onetouch_uuid %>
|
|
24
|
+
<script>
|
|
25
|
+
(function(){
|
|
26
|
+
var onetouchInterval = setInterval(function(){
|
|
27
|
+
var onetouchRequest = new XMLHttpRequest();
|
|
28
|
+
var rememberDevice = document.getElementById("remember_device").checked ? '1' : '0';
|
|
29
|
+
onetouchRequest.addEventListener("load", function(){
|
|
30
|
+
if(this.status != 202) clearInterval(onetouchInterval);
|
|
31
|
+
if(this.status == 200) window.location = JSON.parse(this.responseText).redirect;
|
|
32
|
+
});
|
|
33
|
+
onetouchRequest.open("GET", "<%= polymorphic_path [resource_name, :authy_onetouch_status] %>?remember_device="+rememberDevice+"&onetouch_uuid=<%= @onetouch_uuid %>");
|
|
34
|
+
onetouchRequest.send();
|
|
35
|
+
}, 3000);
|
|
36
|
+
})();
|
|
37
|
+
</script>
|
|
21
38
|
<% end %>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
%h2= I18n.t('authy_register_title',
|
|
1
|
+
%h2= I18n.t('authy_register_title', scope: 'devise')
|
|
2
2
|
|
|
3
3
|
= verify_authy_form do
|
|
4
|
-
%legend= I18n.t('submit_token_title',
|
|
4
|
+
%legend= I18n.t('submit_token_title', scope: 'devise')
|
|
5
5
|
= hidden_field_tag :"#{resource_name}_id", @resource.id
|
|
6
|
-
= label_tag
|
|
7
|
-
= text_field_tag :token, "", :autocomplete => :
|
|
6
|
+
= label_tag 'authy-token'
|
|
7
|
+
= text_field_tag :token, "", :autocomplete => "one-time-code", :inputmode => "numeric", :pattern => "[0-9]*", :id => 'authy-token'
|
|
8
8
|
%label
|
|
9
9
|
= check_box_tag :remember_device
|
|
10
|
-
%span= I18n.t('remember_device',
|
|
10
|
+
%span= I18n.t('remember_device', scope: 'devise')
|
|
11
11
|
|
|
12
12
|
/ Help Tooltip
|
|
13
13
|
/ You need to configure a help message.
|
|
@@ -15,4 +15,19 @@
|
|
|
15
15
|
/ = link_to '?', '#', :id => 'authy-help', :'data-message' => 'a message'
|
|
16
16
|
|
|
17
17
|
= authy_request_sms_link
|
|
18
|
-
= submit_tag I18n.t('submit_token',
|
|
18
|
+
= submit_tag I18n.t('submit_token', scope: 'devise'), :class => 'btn'
|
|
19
|
+
|
|
20
|
+
- if @onetouch_uuid
|
|
21
|
+
:javascript
|
|
22
|
+
(function(){
|
|
23
|
+
var onetouchInterval = setInterval(function(){
|
|
24
|
+
var onetouchRequest = new XMLHttpRequest();
|
|
25
|
+
var rememberDevice = document.getElementById("remember_device").checked ? '1' : '0';
|
|
26
|
+
onetouchRequest.addEventListener("load", function(){
|
|
27
|
+
if(this.status != 202) clearInterval(onetouchInterval);
|
|
28
|
+
if(this.status == 200) window.location = JSON.parse(this.responseText).redirect;
|
|
29
|
+
});
|
|
30
|
+
onetouchRequest.open("GET", "#{polymorphic_path [resource_name, :authy_onetouch_status]}?remember_device="+rememberDevice+"&onetouch_uuid=#{@onetouch_uuid}");
|
|
31
|
+
onetouchRequest.send();
|
|
32
|
+
}, 3000);
|
|
33
|
+
})();
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
<h2><%= I18n.t('authy_verify_installation_title',
|
|
1
|
+
<h2><%= I18n.t('authy_verify_installation_title', scope: 'devise') %></h2>
|
|
2
|
+
|
|
3
|
+
<% if @authy_qr_code %>
|
|
4
|
+
<%= image_tag @authy_qr_code, :size => '256x256', :alt => I18n.t('authy_qr_code_alt', scope: 'devise') %>
|
|
5
|
+
<p><%= I18n.t('authy_qr_code_instructions', scope: 'devise') %></p>
|
|
6
|
+
<% end %>
|
|
2
7
|
|
|
3
8
|
<%= verify_authy_installation_form do %>
|
|
4
|
-
<legend><%= I18n.t('submit_token_title',
|
|
9
|
+
<legend><%= I18n.t('submit_token_title', scope: 'devise') %></legend>
|
|
5
10
|
<%= label_tag :token %>
|
|
6
|
-
<%= text_field_tag :token, "", :autocomplete => :
|
|
11
|
+
<%= text_field_tag :token, "", :autocomplete => "one-time-code", :inputmode => "numeric", :pattern => "[0-9]*", :id => 'authy-token' %>
|
|
12
|
+
<label>
|
|
13
|
+
<%= check_box_tag :remember_device %>
|
|
14
|
+
<span><%= I18n.t('remember_device', scope: 'devise') %></span>
|
|
15
|
+
</label>
|
|
7
16
|
<%= authy_request_sms_link %>
|
|
8
|
-
<%= submit_tag I18n.t('enable_my_account',
|
|
9
|
-
<% end %>
|
|
10
|
-
|
|
17
|
+
<%= submit_tag I18n.t('enable_my_account', scope: 'devise'), :class => 'btn' %>
|
|
18
|
+
<% end %>
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
%h2= I18n.t('authy_verify_installation_title',
|
|
1
|
+
%h2= I18n.t('authy_verify_installation_title', scope: 'devise')
|
|
2
|
+
|
|
3
|
+
- if @authy_qr_code
|
|
4
|
+
= image_tag @authy_qr_code, :size => '256x256', :alt => I18n.t('authy_qr_code_alt', scope: 'devise')
|
|
5
|
+
%p= I18n.t('authy_qr_code_instructions', scope: 'devise')
|
|
6
|
+
|
|
2
7
|
= verify_authy_installation_form do
|
|
3
|
-
%legend= I18n.t('submit_token_title',
|
|
8
|
+
%legend= I18n.t('submit_token_title', scope: 'devise')
|
|
4
9
|
= label_tag :token
|
|
5
|
-
= text_field_tag :token, "", :autocomplete => :
|
|
10
|
+
= text_field_tag :token, "", :autocomplete => "one-time-code", :inputmode => "numeric", :pattern => "[0-9]*", :id => 'authy-token'
|
|
11
|
+
%label
|
|
12
|
+
= check_box_tag :remember_device
|
|
13
|
+
%span= I18n.t('remember_device', scope: 'devise')
|
|
6
14
|
= authy_request_sms_link
|
|
7
|
-
= submit_tag I18n.t('enable_my_account',
|
|
15
|
+
= submit_tag I18n.t('enable_my_account', scope: 'devise'), :class => 'btn'
|
|
8
16
|
|
data/config/locales/en.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
en:
|
|
2
2
|
devise:
|
|
3
|
-
submit_token:
|
|
4
|
-
submit_token_title:
|
|
3
|
+
submit_token: 'Check Token'
|
|
4
|
+
submit_token_title: 'Please enter your Authy token:'
|
|
5
5
|
authy_register_title: 'Enable Two factor authentication'
|
|
6
6
|
enable_authy: 'Enable'
|
|
7
7
|
cellphone: 'Enter your cellphone'
|
|
@@ -9,10 +9,14 @@ en:
|
|
|
9
9
|
request_sms: 'Request SMS'
|
|
10
10
|
request_phone_call: 'Request phone call'
|
|
11
11
|
remember_device: 'Remember Device'
|
|
12
|
+
request_to_login: 'Request to Login'
|
|
12
13
|
|
|
13
|
-
authy_verify_installation_title:
|
|
14
|
+
authy_verify_installation_title: 'Verify your account'
|
|
14
15
|
enable_my_account: 'Enable my account'
|
|
15
16
|
|
|
17
|
+
authy_qr_code_alt: 'QR code for scanning with your authenticator app.'
|
|
18
|
+
authy_qr_code_instructions: 'Scan this QR code with your authenticator application and enter the code below.'
|
|
19
|
+
|
|
16
20
|
devise_authy:
|
|
17
21
|
user:
|
|
18
22
|
enabled: 'Two factor authentication was enabled'
|
|
@@ -20,5 +24,5 @@ en:
|
|
|
20
24
|
disabled: 'Two factor authentication was disabled'
|
|
21
25
|
not_disabled: 'Something went wrong while disabling two factor authentication'
|
|
22
26
|
signed_in: 'Signed in with Authy successfully.'
|
|
23
|
-
already_enabled:
|
|
27
|
+
already_enabled: 'Two factor authentication is already enabled.'
|
|
24
28
|
invalid_token: 'The entered token is invalid'
|