orthodox 0.3.2 → 0.3.6
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/.gitignore +0 -1
- data/.ruby-version +1 -0
- data/.yardopts +7 -0
- data/README.md +3 -3
- data/dummy/.ruby-version +1 -1
- data/dummy/Gemfile +2 -2
- data/dummy/Gemfile.lock +111 -113
- data/lib/generators/authentication/authentication_generator.rb +86 -86
- data/lib/generators/authentication/templates/controllers/concerns/authentication.rb.erb +25 -25
- data/lib/generators/authentication/templates/controllers/password_resets_controller.rb.erb +1 -1
- data/lib/generators/authentication/templates/controllers/sessions_controller.rb.erb +5 -5
- data/lib/generators/authentication/templates/controllers/tfa_sessions_controller.rb.erb +3 -3
- data/lib/generators/authentication/templates/controllers/tfas_controller.rb.erb +3 -3
- data/lib/generators/authentication/templates/helpers/otp_credentials_helper.rb +3 -3
- data/lib/generators/authentication/templates/javascript/tfa_forms.js +3 -5
- data/lib/generators/authentication/templates/models/concerns/authenticateable.rb +3 -3
- data/lib/generators/authentication/templates/models/concerns/otpable.rb +3 -3
- data/lib/generators/authentication/templates/models/concerns/password_resetable.rb +3 -3
- data/lib/generators/authentication/templates/models/otp_credential.rb.erb +3 -3
- data/lib/generators/authentication/templates/models/password_reset_token.rb +3 -3
- data/lib/generators/authentication/templates/models/session.rb.erb +3 -3
- data/lib/generators/authentication/templates/models/tfa_session.rb +2 -2
- data/lib/generators/authentication/templates/spec/models/otp_credential_spec.rb +2 -2
- data/lib/generators/authentication/templates/spec/models/password_reset_token_spec.rb +2 -2
- data/lib/generators/authentication/templates/spec/models/session_spec.rb.erb +10 -11
- data/lib/generators/authentication/templates/spec/models/tfa_session_spec.rb.erb +35 -36
- data/lib/generators/authentication/templates/spec/support/authentication_helpers.rb +3 -3
- data/lib/generators/authentication/templates/spec/system/authentication_spec.rb.erb +2 -2
- data/lib/generators/authentication/templates/spec/system/password_resets_spec.rb.erb +2 -2
- data/lib/generators/authentication/templates/spec/system/tfa_authentication_spec.rb.erb +2 -2
- data/lib/generators/base_controller/base_controller_generator.rb +1 -1
- data/lib/generators/base_controller/templates/base_controller.rb.erb +1 -1
- data/lib/generators/controller/templates/controller.rb.erb +1 -1
- data/lib/generators/layout_helper/layout_helper_generator.rb +1 -1
- data/lib/orthodox/version.rb +1 -1
- data/orthodox.gemspec +5 -7
- metadata +16 -42
@@ -1,41 +1,41 @@
|
|
1
1
|
class AuthenticationGenerator < Rails::Generators::NamedBase
|
2
2
|
source_root File.expand_path('templates', __dir__)
|
3
|
-
|
3
|
+
|
4
4
|
desc "Creates authentication views, controllers and models for a given Model"
|
5
|
-
|
5
|
+
|
6
6
|
class_option :skip_views, type: :boolean, default: false
|
7
7
|
|
8
8
|
class_option :skip_tests, type: :boolean, default: false
|
9
|
-
|
9
|
+
|
10
10
|
class_option :two_factor, type: :boolean, default: false
|
11
|
-
|
11
|
+
|
12
12
|
class_option :js, type: :boolean, default: false
|
13
|
-
|
14
|
-
|
13
|
+
|
14
|
+
|
15
15
|
def create_controllers
|
16
|
-
generate "base_controller",
|
17
|
-
template "controllers/sessions_controller.rb.erb",
|
16
|
+
generate "base_controller", plural_name
|
17
|
+
template "controllers/sessions_controller.rb.erb",
|
18
18
|
"app/controllers/#{plural_file_name}/sessions_controller.rb"
|
19
|
-
template "controllers/password_resets_controller.rb.erb",
|
19
|
+
template "controllers/password_resets_controller.rb.erb",
|
20
20
|
"app/controllers/#{plural_file_name}/password_resets_controller.rb"
|
21
21
|
|
22
|
-
if options[:two_factor]
|
23
|
-
template "controllers/tfa_sessions_controller.rb.erb",
|
22
|
+
if options[:two_factor]
|
23
|
+
template "controllers/tfa_sessions_controller.rb.erb",
|
24
24
|
"app/controllers/#{plural_file_name}/tfa_sessions_controller.rb"
|
25
|
-
|
26
|
-
template "controllers/tfas_controller.rb.erb",
|
25
|
+
|
26
|
+
template "controllers/tfas_controller.rb.erb",
|
27
27
|
"app/controllers/#{plural_file_name}/tfas_controller.rb"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def extend_controllers
|
32
|
-
inject_into_class "app/controllers/#{plural_name}/base_controller.rb",
|
33
|
-
"#{plural_class_name}::BaseController",
|
32
|
+
inject_into_class "app/controllers/#{plural_name}/base_controller.rb",
|
33
|
+
"#{plural_class_name}::BaseController",
|
34
34
|
" authenticate_model :#{singular_name}, tfa: #{options[:two_factor]}\n"
|
35
35
|
include_module_in_controller("#{plural_name}/base_controller", "Authentication")
|
36
|
-
|
36
|
+
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def ensure_helpers
|
40
40
|
if options[:two_factor]
|
41
41
|
copy_file "helpers/otp_credentials_helper.rb", "app/helpers/otp_credentials_helper.rb"
|
@@ -47,7 +47,7 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
47
47
|
copy_file "javascript/tfa_forms.js", "app/javascript/packs/tfa_forms.js"
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def create_mailer
|
52
52
|
generate "mailer", "#{class_name}Mailer"
|
53
53
|
inject_into_class "app/mailers/#{singular_name}_mailer.rb", "#{class_name}Mailer", <<~RUBY
|
@@ -56,47 +56,47 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
56
56
|
@#{singular_name} = #{singular_name}
|
57
57
|
mail(to: #{singular_name}.email, subject: "Reset your password")
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
RUBY
|
61
61
|
template "views/mailers/password_reset_link.html.slim.erb",
|
62
62
|
"app/views/#{singular_name}_mailer/password_reset_link.html.slim"
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
def create_models
|
66
66
|
copy_file "models/password_reset_token.rb", "app/models/password_reset_token.rb"
|
67
67
|
if options[:two_factor]
|
68
68
|
template "models/otp_credential.rb.erb", "app/models/otp_credential.rb"
|
69
|
-
end
|
69
|
+
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
def extend_models
|
73
73
|
include_module_in_model(class_name, "Authenticateable")
|
74
|
-
include_module_in_model(class_name, "PasswordResetable")
|
74
|
+
include_module_in_model(class_name, "PasswordResetable")
|
75
75
|
if options[:two_factor]
|
76
76
|
include_module_in_model(class_name, "Otpable")
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
def create_form_objects
|
81
|
-
template "models/session.rb.erb", "app/models/#{singular_name}_session.rb"
|
81
|
+
template "models/session.rb.erb", "app/models/#{singular_name}_session.rb"
|
82
82
|
if options[:two_factor]
|
83
83
|
copy_file "models/tfa_session.rb", "app/models/tfa_session.rb"
|
84
|
-
end
|
84
|
+
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
def ensure_concerns
|
88
|
-
template "controllers/concerns/authentication.rb.erb",
|
88
|
+
template "controllers/concerns/authentication.rb.erb",
|
89
89
|
"app/controllers/concerns/authentication.rb"
|
90
|
-
copy_file "models/concerns/authenticateable.rb",
|
91
|
-
"app/models/concerns/authenticateable.rb"
|
92
|
-
copy_file "models/concerns/password_resetable.rb",
|
93
|
-
"app/models/concerns/password_resetable.rb"
|
90
|
+
copy_file "models/concerns/authenticateable.rb",
|
91
|
+
"app/models/concerns/authenticateable.rb"
|
92
|
+
copy_file "models/concerns/password_resetable.rb",
|
93
|
+
"app/models/concerns/password_resetable.rb"
|
94
94
|
|
95
95
|
if options[:two_factor]
|
96
|
-
copy_file "controllers/concerns/two_factor_authentication.rb",
|
97
|
-
"app/controllers/concerns/two_factor_authentication.rb"
|
98
|
-
|
99
|
-
copy_file "models/concerns/otpable.rb", "app/models/concerns/otpable.rb"
|
96
|
+
copy_file "controllers/concerns/two_factor_authentication.rb",
|
97
|
+
"app/controllers/concerns/two_factor_authentication.rb"
|
98
|
+
|
99
|
+
copy_file "models/concerns/otpable.rb", "app/models/concerns/otpable.rb"
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -111,64 +111,64 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
111
111
|
secret:string{32} \
|
112
112
|
authable:references{polymorphic} \
|
113
113
|
recovery_codes:json"
|
114
|
-
end
|
114
|
+
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
def create_view_templates
|
118
118
|
return if options[:skip_views]
|
119
|
-
template "views/sessions/new.html.slim.erb",
|
120
|
-
"app/views/#{plural_name}/sessions/new.html.slim"
|
119
|
+
template "views/sessions/new.html.slim.erb",
|
120
|
+
"app/views/#{plural_name}/sessions/new.html.slim"
|
121
|
+
|
122
|
+
template "views/password_resets/new.html.slim.erb",
|
123
|
+
"app/views/#{plural_name}/password_resets/new.html.slim"
|
121
124
|
|
122
|
-
template "views/password_resets/
|
123
|
-
"app/views/#{plural_name}/password_resets/
|
125
|
+
template "views/password_resets/edit.html.slim.erb",
|
126
|
+
"app/views/#{plural_name}/password_resets/edit.html.slim"
|
124
127
|
|
125
|
-
template "views/password_resets/edit.html.slim.erb",
|
126
|
-
"app/views/#{plural_name}/password_resets/edit.html.slim"
|
127
|
-
|
128
128
|
if options[:two_factor]
|
129
|
-
template "views/tfa_sessions/new.html.slim.erb",
|
130
|
-
"app/views/#{plural_name}/tfa_sessions/new.html.slim"
|
131
|
-
template "views/tfas/show.html.slim.erb",
|
132
|
-
"app/views/#{plural_name}/tfas/show.html.slim"
|
133
|
-
|
129
|
+
template "views/tfa_sessions/new.html.slim.erb",
|
130
|
+
"app/views/#{plural_name}/tfa_sessions/new.html.slim"
|
131
|
+
template "views/tfas/show.html.slim.erb",
|
132
|
+
"app/views/#{plural_name}/tfas/show.html.slim"
|
133
|
+
|
134
134
|
end
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
def create_specs
|
138
138
|
return if options[:skip_tests]
|
139
|
-
|
139
|
+
|
140
140
|
copy_file "spec/support/factory_bot.rb", "spec/support/factory_bot.rb"
|
141
|
-
|
142
|
-
template "spec/system/authentication_spec.rb.erb",
|
143
|
-
"spec/system/#{plural_name}/authentication_spec.rb"
|
144
|
-
|
145
|
-
template "spec/system/password_resets_spec.rb.erb",
|
146
|
-
"spec/system/#{plural_name}/password_resets_spec.rb"
|
147
|
-
|
148
|
-
template "spec/models/session_spec.rb.erb",
|
149
|
-
"spec/models/#{singular_name}_session_spec.rb"
|
150
|
-
|
151
|
-
copy_file "spec/models/password_reset_token_spec.rb",
|
141
|
+
|
142
|
+
template "spec/system/authentication_spec.rb.erb",
|
143
|
+
"spec/system/#{plural_name}/authentication_spec.rb"
|
144
|
+
|
145
|
+
template "spec/system/password_resets_spec.rb.erb",
|
146
|
+
"spec/system/#{plural_name}/password_resets_spec.rb"
|
147
|
+
|
148
|
+
template "spec/models/session_spec.rb.erb",
|
149
|
+
"spec/models/#{singular_name}_session_spec.rb"
|
150
|
+
|
151
|
+
copy_file "spec/models/password_reset_token_spec.rb",
|
152
152
|
"spec/models/password_reset_token_spec.rb"
|
153
|
-
|
153
|
+
|
154
154
|
if options[:two_factor]
|
155
|
-
copy_file "spec/support/authentication_helpers.rb",
|
155
|
+
copy_file "spec/support/authentication_helpers.rb",
|
156
156
|
"spec/support/authentication_helpers.rb"
|
157
157
|
template "spec/models/tfa_session_spec.rb.erb", "spec/models/tfa_session_spec.rb"
|
158
|
-
copy_file "spec/models/otp_credential_spec.rb",
|
159
|
-
"spec/models/otp_credential_spec.rb"
|
160
|
-
template "spec/system/tfa_authentication_spec.rb.erb",
|
161
|
-
"spec/system/#{plural_name}/tfa_authentication_spec.rb"
|
162
|
-
|
158
|
+
copy_file "spec/models/otp_credential_spec.rb",
|
159
|
+
"spec/models/otp_credential_spec.rb"
|
160
|
+
template "spec/system/tfa_authentication_spec.rb.erb",
|
161
|
+
"spec/system/#{plural_name}/tfa_authentication_spec.rb"
|
162
|
+
|
163
163
|
end
|
164
164
|
end
|
165
|
-
|
165
|
+
|
166
166
|
def create_factories
|
167
167
|
generate "factory_bot:model", "otp_credential"
|
168
168
|
generate "factory_bot:model", "password_reset_token"
|
169
|
-
generate "factory_bot:model", "#{singular_name}_session email:email password:password"
|
169
|
+
generate "factory_bot:model", "#{singular_name}_session email:email password:password"
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
def ensure_gems
|
173
173
|
gem "validates_email_format_of", version: "~> 1.6"
|
174
174
|
gem "slim-rails"
|
@@ -179,39 +179,39 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
179
179
|
gem "rqrcode", require: false
|
180
180
|
end
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
def create_routes
|
184
184
|
route <<~RUBY
|
185
185
|
namespace :#{plural_name} do
|
186
|
-
|
186
|
+
|
187
187
|
resource :session, only: [:new, :create, :destroy]
|
188
|
-
|
188
|
+
|
189
189
|
#{"resource :tfa_session, only: [:new, :create]" if options[:two_factor]}
|
190
|
-
|
190
|
+
|
191
191
|
resource :tfa, only: [:create, :show, :destroy]
|
192
|
-
|
192
|
+
|
193
193
|
resources :password_resets, only: [:new, :create, :edit, :update], param: :token
|
194
|
-
|
194
|
+
|
195
195
|
end
|
196
196
|
RUBY
|
197
197
|
end
|
198
|
-
|
198
|
+
|
199
199
|
private
|
200
|
-
|
200
|
+
|
201
201
|
def plural_class_name
|
202
202
|
class_name.pluralize
|
203
203
|
end
|
204
204
|
|
205
205
|
def include_module_in_controller(controller_name, module_name)
|
206
206
|
class_name = controller_name.classify
|
207
|
-
inject_into_class "app/controllers/#{controller_name}.rb", class_name,
|
207
|
+
inject_into_class "app/controllers/#{controller_name}.rb", class_name,
|
208
208
|
" include #{module_name}\n"
|
209
|
-
|
209
|
+
|
210
210
|
end
|
211
|
-
|
211
|
+
|
212
212
|
def include_module_in_model(model_name, module_name)
|
213
|
-
inject_into_class "app/models/#{model_name.underscore}.rb", model_name,
|
213
|
+
inject_into_class "app/models/#{model_name.underscore}.rb", model_name,
|
214
214
|
" include #{module_name}\n"
|
215
|
-
|
215
|
+
|
216
216
|
end
|
217
217
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Concern added to controllres to provide methods for authentication.
|
4
4
|
#
|
5
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
6
|
-
|
5
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
6
|
+
|
7
7
|
module Authentication
|
8
|
-
|
8
|
+
|
9
9
|
extend ActiveSupport::Concern
|
10
|
-
|
10
|
+
|
11
11
|
protected
|
12
|
-
|
12
|
+
|
13
13
|
# Sign in a given record as a given type
|
14
14
|
#
|
15
15
|
# record - An AppliationRecord subclass instance (e.g. A Member)
|
@@ -25,7 +25,7 @@ module Authentication
|
|
25
25
|
session[:"#{as}_tfa_authenticated"] = tfa
|
26
26
|
<%- end -%>
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
# Sign out a given record type.
|
30
30
|
#
|
31
31
|
# as - A String or Symbol with the model name (e.g. "member")
|
@@ -36,11 +36,11 @@ module Authentication
|
|
36
36
|
<%- end -%>
|
37
37
|
instance_variable_set("@current_#{as}", nil)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
module ClassMethods
|
41
|
-
|
41
|
+
|
42
42
|
# Create a bunch of authentication methods for a given ActiveRecord model
|
43
|
-
def authenticate_model(model_name, **options)
|
43
|
+
def authenticate_model(model_name, **options)
|
44
44
|
# Define a current_<model> method to load the currently signed in record, if present
|
45
45
|
#
|
46
46
|
# Returns ApplicationRecord subclass
|
@@ -50,24 +50,24 @@ module Authentication
|
|
50
50
|
instance_variable_get(instance_method_name)
|
51
51
|
else
|
52
52
|
scope = send(:"#{model_name}_auth_scope")
|
53
|
-
instance_variable_set(instance_method_name,
|
53
|
+
instance_variable_set(instance_method_name,
|
54
54
|
scope.find_by(id: session[:"#{model_name}_id"]))
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
# Define a controller before_action method to authenticate a record for the given
|
59
59
|
# model. Redirects to the <model_name>_failed_authentication_url if not passed.
|
60
60
|
#
|
61
61
|
# Returns nil
|
62
62
|
define_method(:"authenticate_#{model_name}") do
|
63
63
|
unless send(:"current_#{model_name}?")
|
64
|
-
redirect_to send(:"#{model_name}_failed_authentication_url"),
|
64
|
+
redirect_to send(:"#{model_name}_failed_authentication_url"),
|
65
65
|
warn: "You must be signed in to do that"
|
66
|
-
end
|
66
|
+
end
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
before_action :"authenticate_#{model_name}"
|
70
|
-
|
70
|
+
|
71
71
|
# Creates a scope that records are loaded through when being authenticated. Subclass
|
72
72
|
# this method to customise the load conditions.
|
73
73
|
#
|
@@ -75,37 +75,37 @@ module Authentication
|
|
75
75
|
define_method(:"#{model_name}_auth_scope") do
|
76
76
|
model_name.to_s.classify.constantize.all
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
# Creates a boolean method to check if a current_<model_name> has been authenticated
|
80
80
|
# or not.
|
81
81
|
#
|
82
82
|
# Returns Boolean
|
83
83
|
define_method(:"current_#{model_name}?") { send(:"current_#{model_name}").present? }
|
84
|
-
|
85
|
-
define_method(:"#{model_name}_signed_in?") { send(:"current_#{model_name}?") }
|
86
|
-
|
84
|
+
|
85
|
+
define_method(:"#{model_name}_signed_in?") { send(:"current_#{model_name}?") }
|
86
|
+
|
87
87
|
define_method(:"#{model_name}_failed_authentication_url") do
|
88
88
|
send(:"new_#{model_name.to_s.pluralize}_session_url")
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
helper_method :"current_#{model_name}"
|
92
92
|
helper_method :"current_#{model_name}?"
|
93
93
|
helper_method :"#{model_name}_signed_in?"
|
94
|
-
|
94
|
+
|
95
95
|
protected :"current_#{model_name}"
|
96
96
|
protected :"current_#{model_name}?"
|
97
97
|
protected :"#{model_name}_signed_in?"
|
98
98
|
protected :"authenticate_#{model_name}"
|
99
|
-
|
99
|
+
|
100
100
|
<%- if options[:two_factor] -%>
|
101
101
|
# This is included if the authentication generator is run with --two-factor=true
|
102
102
|
if options[:tfa] == true
|
103
|
-
include TwoFactorAuthentication
|
103
|
+
include TwoFactorAuthentication
|
104
104
|
define_tfa_methods(model_name)
|
105
105
|
end
|
106
106
|
<%- end -%>
|
107
107
|
end
|
108
108
|
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Controller for managing sessions for <%= plural_class_name %>.
|
4
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
5
|
-
|
4
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
5
|
+
|
6
6
|
class <%= plural_class_name %>::SessionsController < <%= plural_class_name %>::BaseController
|
7
|
-
|
7
|
+
|
8
8
|
skip_before_action :authenticate_<%= singular_name %>
|
9
9
|
|
10
10
|
def new
|
@@ -20,7 +20,7 @@ class <%= plural_class_name %>::SessionsController < <%= plural_class_name %>::B
|
|
20
20
|
render :new
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def destroy
|
25
25
|
sign_out(:<%= singular_name %>)
|
26
26
|
redirect_to root_url, notice: "Successfully signed out"
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# Controller for managing two-factor sessions for <%= plural_class_name %>.
|
4
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
5
|
-
|
4
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
5
|
+
|
6
6
|
class <%= plural_class_name %>::TfaSessionsController < <%= plural_class_name %>::BaseController
|
7
7
|
|
8
8
|
skip_before_action :authenticate_<%= singular_name %>
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# Controller for managing two-factor credentials for <%= plural_class_name %>.
|
4
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
5
|
-
|
4
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
5
|
+
|
6
6
|
class <%= plural_class_name %>::TfasController < <%= plural_class_name %>::BaseController
|
7
7
|
|
8
8
|
skip_before_action :authenticate_<%= singular_name %>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Helper for one-time-password authentication methods
|
4
4
|
#
|
5
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
6
|
-
|
5
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
6
|
+
|
7
7
|
module OtpCredentialsHelper
|
8
8
|
|
9
9
|
require 'rqrcode'
|
@@ -1,9 +1,7 @@
|
|
1
|
-
// Basic JS functionality for one-time-password form. Designed to be used with jQuery and
|
1
|
+
// Basic JS functionality for one-time-password form. Designed to be used with jQuery and
|
2
2
|
// Bootstrap.
|
3
3
|
//
|
4
|
-
// Automatically generated by the orthodox gem (https://github.com/
|
5
|
-
// (c) Copyright 2019 Katana Code Ltd. All Rights Reserved.
|
6
|
-
|
4
|
+
// Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
7
5
|
// Initialize method called when jQuery ready
|
8
6
|
function init() {
|
9
7
|
$("body").on("click", ".js-tfa-link", onClick);
|
@@ -16,4 +14,4 @@ function onClick(e){
|
|
16
14
|
$(".js-tfa-field-group").toggleClass("d-none");
|
17
15
|
}
|
18
16
|
|
19
|
-
jQuery(init);
|
17
|
+
jQuery(init);
|
@@ -1,9 +1,9 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Model concern to provide shared behaviour for authenticating records.
|
4
4
|
#
|
5
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
6
|
-
|
5
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
6
|
+
|
7
7
|
module Authenticateable
|
8
8
|
|
9
9
|
extend ActiveSupport::Concern
|
@@ -1,9 +1,9 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# Model concern to provide shared behaviour for two-factor auth (one-time password)
|
4
4
|
#
|
5
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
6
|
-
|
5
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
6
|
+
|
7
7
|
module Otpable
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# Model concern to provide shared behaviour for password resets
|
4
4
|
#
|
5
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
6
|
-
|
5
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
6
|
+
|
7
7
|
module PasswordResetable
|
8
8
|
|
9
9
|
extend ActiveSupport::Concern
|
@@ -1,9 +1,9 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# Model for managing one-time password credentials for a given Member
|
4
4
|
#
|
5
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
6
|
-
|
5
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
6
|
+
|
7
7
|
#
|
8
8
|
# == Schema Information
|
9
9
|
#
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
4
|
# Model for managing password reset tokens
|
5
5
|
#
|
6
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
7
|
-
|
6
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
7
|
+
|
8
8
|
#
|
9
9
|
# == Schema Information
|
10
10
|
#
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# frozen_string_literal
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Form object for authenticating <%= class_name %> records.
|
4
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
5
|
-
|
4
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
5
|
+
|
6
6
|
class <%= class_name %>Session
|
7
7
|
|
8
8
|
include ActiveModel::Model
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Form object for handling two-factor authentication sessions
|
2
2
|
#
|
3
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
4
|
-
|
3
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
4
|
+
|
5
5
|
class TfaSession
|
6
6
|
include ActiveModel::Model
|
7
7
|
include ActiveModel::Attributes
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
2
|
-
|
1
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
2
|
+
|
3
3
|
#
|
4
4
|
# == Schema Information
|
5
5
|
#
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# Automatically generated by the orthodox gem (https://github.com/
|
2
|
-
|
1
|
+
# Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox)
|
2
|
+
|
3
3
|
#
|
4
4
|
# == Schema Information
|
5
5
|
#
|