rodauth-rails 0.18.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -0
- data/LICENSE.txt +1 -1
- data/README.md +366 -651
- data/lib/generators/rodauth/install_generator.rb +32 -35
- data/lib/generators/rodauth/migration/active_sessions.erb +2 -2
- data/lib/generators/rodauth/migration/audit_logging.erb +1 -1
- data/lib/generators/rodauth/migration/base.erb +2 -2
- data/lib/generators/rodauth/migration/email_auth.erb +1 -1
- data/lib/generators/rodauth/migration/otp.erb +1 -1
- data/lib/generators/rodauth/migration/password_expiration.erb +1 -1
- data/lib/generators/rodauth/migration/reset_password.erb +1 -1
- data/lib/generators/rodauth/migration/sms_codes.erb +1 -1
- data/lib/generators/rodauth/migration/verify_account.erb +2 -2
- data/lib/generators/rodauth/migration/webauthn.erb +1 -1
- data/lib/generators/rodauth/migration_generator.rb +9 -2
- data/lib/generators/rodauth/migration_helpers.rb +8 -0
- data/lib/generators/rodauth/templates/INSTRUCTIONS +40 -0
- data/lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb +36 -19
- data/lib/generators/rodauth/templates/app/misc/rodauth_app.rb +27 -0
- data/lib/generators/rodauth/templates/app/{lib/rodauth_app.rb → misc/rodauth_main.rb} +10 -56
- data/lib/generators/rodauth/templates/app/models/account.rb +1 -0
- data/lib/generators/rodauth/templates/app/views/rodauth/_email_auth_request_form.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/change_login.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/change_password.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/close_account.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/confirm_password.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/create_account.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/email_auth.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/logout.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_auth.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_disable.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_setup.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/recovery_auth.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/remember.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/reset_password.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/reset_password_request.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_auth.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_confirm.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_disable.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_request.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_setup.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_disable.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/unlock_account.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/unlock_account_request.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_account.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_account_resend.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_login_change.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_auth.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_remove.html.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_setup.html.erb +1 -1
- data/lib/rodauth/rails/app.rb +18 -4
- data/lib/rodauth/rails/auth.rb +1 -16
- data/lib/rodauth/rails/controller_methods.rb +4 -29
- data/lib/rodauth/rails/feature/base.rb +21 -0
- data/lib/rodauth/rails/feature/internal_request.rb +10 -4
- data/lib/rodauth/rails/feature/render.rb +8 -0
- data/lib/rodauth/rails/tasks.rake +2 -2
- data/lib/rodauth/rails/version.rb +1 -1
- data/lib/rodauth/rails.rb +9 -20
- data/rodauth-rails.gemspec +2 -2
- metadata +10 -8
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.reset_password_request_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.reset_password_request_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.reset_password_request_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<%== rodauth.reset_password_explanatory_text %>
|
5
5
|
|
6
6
|
<% if params[rodauth.login_param] && !rodauth.field_error(rodauth.login_param) %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.sms_auth_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.sms_auth_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.sms_auth_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<div class="form-group mb-3">
|
5
5
|
<%= form.label "sms-code", rodauth.sms_code_label, class: "form-label" %>
|
6
6
|
<div class="row">
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.sms_confirm_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.sms_confirm_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.sms_confirm_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<div class="form-group mb-3">
|
5
5
|
<%= form.label "sms-code", rodauth.sms_code_label, class: "form-label" %>
|
6
6
|
<div class="row">
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.sms_disable_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.sms_disable_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.sms_disable_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<% if rodauth.two_factor_modifications_require_password? %>
|
5
5
|
<div class="form-group mb-3">
|
6
6
|
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.sms_request_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.sms_request_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.sms_request_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<div class="form-group mb-3">
|
5
5
|
<%= form.submit rodauth.sms_request_button, class: "btn btn-primary" %>
|
6
6
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.sms_setup_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.sms_setup_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.sms_setup_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<% if rodauth.two_factor_modifications_require_password? %>
|
5
5
|
<div class="form-group mb-3">
|
6
6
|
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.two_factor_disable_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.two_factor_disable_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.two_factor_disable_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<% if rodauth.two_factor_modifications_require_password? %>
|
5
5
|
<div class="form-group mb-3">
|
6
6
|
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.unlock_account_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.unlock_account_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.unlock_account_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<%== rodauth.unlock_account_explanatory_text %>
|
5
5
|
|
6
6
|
<% if rodauth.unlock_account_requires_password? %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.unlock_account_request_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.unlock_account_request_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.unlock_account_request_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<%= form.hidden_field rodauth.login_param, value: params[rodauth.login_param] %>
|
5
5
|
|
6
6
|
<%== rodauth.unlock_account_request_explanatory_text %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.verify_account_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.verify_account_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.verify_account_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<% if rodauth.verify_account_set_password? %>
|
5
5
|
<div class="form-group mb-3">
|
6
6
|
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.resend_verify_account_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.verify_account_resend_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.verify_account_resend_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<%== rodauth.verify_account_resend_explanatory_text %>
|
5
5
|
|
6
6
|
<% if params[rodauth.login_param] %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.verify_login_change_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.verify_login_change_path, method: :post do |form| %>
|
3
|
+
<%= form_with url: rodauth.verify_login_change_path, method: :post, data: { turbo: false } do |form| %>
|
4
4
|
<div class="form-group mb-3">
|
5
5
|
<%= form.submit rodauth.verify_login_change_button, class: "btn btn-primary" %>
|
6
6
|
</div>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<% cred = rodauth.webauth_credential_options_for_get %>
|
4
4
|
|
5
|
-
<%= form_with url: rodauth.webauthn_auth_form_path, method: :post, id: "webauthn-auth-form", data: { credential_options: cred.as_json.to_json } do |form| %>
|
5
|
+
<%= form_with url: rodauth.webauthn_auth_form_path, method: :post, id: "webauthn-auth-form", data: { credential_options: cred.as_json.to_json, turbo: false } do |form| %>
|
6
6
|
<%= form.hidden_field rodauth.login_param, value: params[rodauth.login_param] %>
|
7
7
|
<%= form.hidden_field rodauth.webauthn_auth_challenge_param, value: cred.challenge %>
|
8
8
|
<%= form.hidden_field rodauth.webauthn_auth_challenge_hmac_param, value: rodauth.compute_hmac(cred.challenge) %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :title, rodauth.webauthn_remove_page_title %>
|
2
2
|
|
3
|
-
<%= form_with url: rodauth.webauthn_remove_path, method: :post, id: "webauthn-remove-form" do |form| %>
|
3
|
+
<%= form_with url: rodauth.webauthn_remove_path, method: :post, id: "webauthn-remove-form", data: { turbo: false } do |form| %>
|
4
4
|
<% if rodauth.two_factor_modifications_require_password? %>
|
5
5
|
<div class="form-group mb-3">
|
6
6
|
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<% cred = rodauth.new_webauthn_credential %>
|
4
4
|
|
5
|
-
<%= form_with url: rodauth.webauthn_setup_path, method: :post, id: "webauthn-setup-form", data: { credential_options: cred.as_json.to_json } do |form| %>
|
5
|
+
<%= form_with url: rodauth.webauthn_setup_path, method: :post, id: "webauthn-setup-form", data: { credential_options: cred.as_json.to_json, turbo: false } do |form| %>
|
6
6
|
<%= form.hidden_field rodauth.webauthn_setup_challenge_param, value: cred.challenge %>
|
7
7
|
<%= form.hidden_field rodauth.webauthn_setup_challenge_hmac_param, value: rodauth.compute_hmac(cred.challenge) %>
|
8
8
|
<%= form.text_field rodauth.webauthn_setup_param, value: "", id: "webauthn-setup", aria: { hidden: "true" } %>
|
data/lib/rodauth/rails/app.rb
CHANGED
@@ -10,7 +10,6 @@ module Rodauth
|
|
10
10
|
|
11
11
|
plugin :hooks
|
12
12
|
plugin :render, layout: false
|
13
|
-
plugin :pass
|
14
13
|
|
15
14
|
unless Rodauth::Rails.api_only?
|
16
15
|
require "rodauth/rails/app/flash"
|
@@ -25,9 +24,9 @@ module Rodauth
|
|
25
24
|
|
26
25
|
auth_class ||= Class.new(Rodauth::Rails::Auth)
|
27
26
|
|
28
|
-
plugin :rodauth, auth_class: auth_class, name: name, csrf: false, flash: false, json: true, **options
|
29
|
-
|
30
|
-
|
27
|
+
plugin :rodauth, auth_class: auth_class, name: name, csrf: false, flash: false, json: true, **options, &block
|
28
|
+
|
29
|
+
self::RodaRequest.include RequestMethods
|
31
30
|
end
|
32
31
|
|
33
32
|
before do
|
@@ -47,6 +46,21 @@ module Rodauth
|
|
47
46
|
def self.rodauth!(name)
|
48
47
|
rodauth(name) or fail ArgumentError, "unknown rodauth configuration: #{name.inspect}"
|
49
48
|
end
|
49
|
+
|
50
|
+
module RequestMethods
|
51
|
+
def rodauth(name = nil)
|
52
|
+
prefix = scope.rodauth(name).prefix
|
53
|
+
|
54
|
+
if prefix.present? && remaining_path == path_info
|
55
|
+
on prefix[1..-1] do
|
56
|
+
super
|
57
|
+
break # forward other `{prefix}/*` requests to the rails router
|
58
|
+
end
|
59
|
+
else
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
50
64
|
end
|
51
65
|
end
|
52
66
|
end
|
data/lib/rodauth/rails/auth.rb
CHANGED
@@ -3,23 +3,8 @@ require "rodauth/rails/feature"
|
|
3
3
|
|
4
4
|
module Rodauth
|
5
5
|
module Rails
|
6
|
-
# Base auth class that applies some default configuration
|
7
|
-
# multi-level inheritance.
|
6
|
+
# Base auth class that applies some changes to the default configuration.
|
8
7
|
class Auth < Rodauth::Auth
|
9
|
-
def self.inherited(subclass)
|
10
|
-
super
|
11
|
-
superclass = self
|
12
|
-
subclass.class_eval do
|
13
|
-
@roda_class = Rodauth::Rails.app
|
14
|
-
@features = superclass.features.clone
|
15
|
-
@routes = superclass.routes.clone
|
16
|
-
@route_hash = superclass.route_hash.clone
|
17
|
-
@configuration = superclass.instance_variable_get(:@configuration).clone
|
18
|
-
@configuration.instance_variable_set(:@auth, self)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# apply default configuration
|
23
8
|
configure do
|
24
9
|
enable :rails
|
25
10
|
|
@@ -8,41 +8,16 @@ module Rodauth
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def rodauth(name = nil)
|
12
|
-
request.env.fetch ["rodauth", *name].join(".")
|
13
|
-
end
|
14
|
-
|
15
11
|
def current_account(name = nil)
|
16
|
-
|
17
|
-
|
12
|
+
rodauth(name).rails_account || rodauth(name).login_required
|
13
|
+
end
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
rodauth(name).clear_session
|
22
|
-
rodauth(name).login_required
|
23
|
-
end
|
15
|
+
def rodauth(name = nil)
|
16
|
+
request.env.fetch ["rodauth", *name].join(".")
|
24
17
|
end
|
25
18
|
|
26
19
|
private
|
27
20
|
|
28
|
-
def fetch_account(model, id, ¬_found)
|
29
|
-
if defined?(ActiveRecord::Base) && model < ActiveRecord::Base
|
30
|
-
begin
|
31
|
-
model.find(id)
|
32
|
-
rescue ActiveRecord::RecordNotFound
|
33
|
-
not_found.call
|
34
|
-
end
|
35
|
-
elsif model < Sequel::Model
|
36
|
-
begin
|
37
|
-
model.with_pk!(id)
|
38
|
-
rescue Sequel::NoMatchingRow
|
39
|
-
not_found.call
|
40
|
-
end
|
41
|
-
else
|
42
|
-
fail Error, "unsupported model type: #{model}"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
21
|
def rodauth_response
|
47
22
|
res = catch(:halt) { return yield }
|
48
23
|
|
@@ -8,6 +8,17 @@ module Rodauth
|
|
8
8
|
feature.auth_cached_method :rails_controller_instance
|
9
9
|
end
|
10
10
|
|
11
|
+
def rails_account
|
12
|
+
account_from_session unless account
|
13
|
+
|
14
|
+
unless account
|
15
|
+
clear_session if logged_in?
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
@rails_account ||= instantiate_rails_account
|
20
|
+
end
|
21
|
+
|
11
22
|
# Reset Rails session to protect from session fixation attacks.
|
12
23
|
def clear_session
|
13
24
|
rails_controller_instance.reset_session
|
@@ -43,6 +54,16 @@ module Rodauth
|
|
43
54
|
|
44
55
|
private
|
45
56
|
|
57
|
+
def instantiate_rails_account
|
58
|
+
if defined?(ActiveRecord::Base) && rails_account_model < ActiveRecord::Base
|
59
|
+
rails_account_model.instantiate(account.stringify_keys)
|
60
|
+
elsif defined?(Sequel::Model) && rails_account_model < Sequel::Model
|
61
|
+
rails_account_model.load(account)
|
62
|
+
else
|
63
|
+
fail Error, "unsupported model type: #{rails_account_model}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
46
67
|
# Instances of the configured controller with current request's env hash.
|
47
68
|
def _rails_controller_instance
|
48
69
|
controller = rails_controller.new
|
@@ -5,16 +5,17 @@ module Rodauth
|
|
5
5
|
def domain
|
6
6
|
return super unless missing_host?
|
7
7
|
|
8
|
-
|
8
|
+
rails_url_options.fetch(:host)
|
9
9
|
end
|
10
10
|
|
11
11
|
def base_url
|
12
12
|
return super unless missing_host? && domain
|
13
13
|
|
14
|
-
|
14
|
+
scheme = rails_url_options[:protocol] || "http"
|
15
|
+
port = rails_url_options[:port]
|
15
16
|
|
16
|
-
url = "#{
|
17
|
-
url << ":#{
|
17
|
+
url = "#{scheme}://#{domain}"
|
18
|
+
url << ":#{port}" if port
|
18
19
|
url
|
19
20
|
end
|
20
21
|
|
@@ -40,6 +41,11 @@ module Rodauth
|
|
40
41
|
def missing_host?
|
41
42
|
internal_request? && request.host == INVALID_DOMAIN || scope.nil?
|
42
43
|
end
|
44
|
+
|
45
|
+
def rails_url_options
|
46
|
+
::Rails.application.config.action_mailer.default_url_options or
|
47
|
+
fail Error, "There is no information to set the URL host from. Please set config.action_mailer.default_url_options in your Rails application, or configure #domain and #base_url in your Rodauth configuration."
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
@@ -42,6 +42,14 @@ module Rodauth
|
|
42
42
|
controller.formats = rails_request.formats.map(&:ref).compact
|
43
43
|
controller
|
44
44
|
end
|
45
|
+
|
46
|
+
# Not all Rodauth actions are Turbo-compatible (some form submissions
|
47
|
+
# render 200 HTML responses), so we disable Turbo on all Rodauth forms.
|
48
|
+
def _view(meth, *)
|
49
|
+
html = super
|
50
|
+
html = html.gsub(/<form(.+)>/, '<form\1 data-turbo="false">') if meth == :view
|
51
|
+
html
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
@@ -5,13 +5,13 @@ namespace :rodauth do
|
|
5
5
|
puts "Routes handled by #{app}:"
|
6
6
|
|
7
7
|
app.opts[:rodauths].each do |configuration_name, auth_class|
|
8
|
-
auth_class.
|
8
|
+
rodauth = auth_class.allocate
|
9
9
|
|
10
10
|
routes = auth_class.routes.map do |handle_method|
|
11
11
|
path_method = "#{handle_method.to_s.sub(/\Ahandle_/, "")}_path"
|
12
12
|
|
13
13
|
[
|
14
|
-
|
14
|
+
rodauth.public_send(path_method),
|
15
15
|
"rodauth#{configuration_name && "(:#{configuration_name})"}.#{path_method}",
|
16
16
|
]
|
17
17
|
end
|
data/lib/rodauth/rails.rb
CHANGED
@@ -14,37 +14,32 @@ module Rodauth
|
|
14
14
|
@app = nil
|
15
15
|
@middleware = true
|
16
16
|
|
17
|
-
LOCK = Mutex.new
|
18
|
-
|
19
17
|
class << self
|
20
18
|
def rodauth(name = nil, query: nil, form: nil, account: nil, **options)
|
21
19
|
auth_class = app.rodauth!(name)
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
auth_class.configure { enable :internal_request }
|
26
|
-
warn "Rodauth::Rails.rodauth requires the internal_request feature to be enabled. For now it was enabled automatically, but this behaviour will be removed in version 1.0."
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
if query || form
|
31
|
-
warn "The :query and :form keyword arguments for Rodauth::Rails.rodauth have been deprecated. Please use the :params argument supported by internal_request feature instead."
|
32
|
-
options[:params] = query || form
|
21
|
+
unless auth_class.features.include?(:internal_request)
|
22
|
+
fail Rodauth::Rails::Error, "Rodauth::Rails.rodauth requires internal_request feature to be enabled"
|
33
23
|
end
|
34
24
|
|
35
25
|
if account
|
36
26
|
options[:account_id] = account.id
|
37
27
|
end
|
38
28
|
|
39
|
-
auth_class.internal_request_eval(options) do
|
29
|
+
instance = auth_class.internal_request_eval(options) do
|
40
30
|
if defined?(ActiveRecord::Base) && account.is_a?(ActiveRecord::Base)
|
41
31
|
@account = account.attributes.symbolize_keys
|
42
32
|
elsif defined?(Sequel::Model) && account.is_a?(Sequel::Model)
|
43
33
|
@account = account.values
|
44
34
|
end
|
45
|
-
|
46
35
|
self
|
47
36
|
end
|
37
|
+
|
38
|
+
# clean up inspect output
|
39
|
+
instance.remove_instance_variable(:@internal_request_block)
|
40
|
+
instance.remove_instance_variable(:@internal_request_return_value)
|
41
|
+
|
42
|
+
instance
|
48
43
|
end
|
49
44
|
|
50
45
|
def model(name = nil, **options)
|
@@ -80,12 +75,6 @@ module Rodauth
|
|
80
75
|
end
|
81
76
|
end
|
82
77
|
|
83
|
-
def url_options
|
84
|
-
options = ::Rails.application.config.action_mailer.default_url_options || {}
|
85
|
-
options[:protocol] ||= "http"
|
86
|
-
options
|
87
|
-
end
|
88
|
-
|
89
78
|
def configure
|
90
79
|
yield self
|
91
80
|
end
|
data/rodauth-rails.gemspec
CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*", "*.gemspec"]
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency "railties", ">= 4.2", "<
|
20
|
-
spec.add_dependency "rodauth", "~> 2.
|
19
|
+
spec.add_dependency "railties", ">= 4.2", "< 8"
|
20
|
+
spec.add_dependency "rodauth", "~> 2.19"
|
21
21
|
spec.add_dependency "sequel-activerecord_connection", "~> 1.1"
|
22
22
|
spec.add_dependency "tilt"
|
23
23
|
spec.add_dependency "bcrypt"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodauth-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,21 +29,21 @@ dependencies:
|
|
29
29
|
version: '4.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rodauth
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '2.
|
39
|
+
version: '2.19'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '2.
|
46
|
+
version: '2.19'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sequel-activerecord_connection
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,9 +173,11 @@ files:
|
|
173
173
|
- lib/generators/rodauth/migration/webauthn.erb
|
174
174
|
- lib/generators/rodauth/migration_generator.rb
|
175
175
|
- lib/generators/rodauth/migration_helpers.rb
|
176
|
+
- lib/generators/rodauth/templates/INSTRUCTIONS
|
176
177
|
- lib/generators/rodauth/templates/app/controllers/rodauth_controller.rb
|
177
|
-
- lib/generators/rodauth/templates/app/lib/rodauth_app.rb
|
178
178
|
- lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb
|
179
|
+
- lib/generators/rodauth/templates/app/misc/rodauth_app.rb
|
180
|
+
- lib/generators/rodauth/templates/app/misc/rodauth_main.rb
|
179
181
|
- lib/generators/rodauth/templates/app/models/account.rb
|
180
182
|
- lib/generators/rodauth/templates/app/views/rodauth/_email_auth_request_form.html.erb
|
181
183
|
- lib/generators/rodauth/templates/app/views/rodauth/_login_form.html.erb
|
@@ -266,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
268
|
- !ruby/object:Gem::Version
|
267
269
|
version: '0'
|
268
270
|
requirements: []
|
269
|
-
rubygems_version: 3.
|
271
|
+
rubygems_version: 3.3.3
|
270
272
|
signing_key:
|
271
273
|
specification_version: 4
|
272
274
|
summary: Provides Rails integration for Rodauth.
|