rodauth-rails 2.2.2 → 2.2.3
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ee1baf96e7272819b654ff2ef0153dfc5ff8c8c09547e9b1db848f7daec7949
|
|
4
|
+
data.tar.gz: 58d00e15bde03f30862186d242f9928d17082bf800abf28528782ce492d6081c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 634d5ba134c9c0c5757ede2aa25a9700252e8026201be0a6694df46d74430b793b4e5272fe835a3ec07291b0ef61860f106f1738e40c6fec7e2552ea82d48dc8
|
|
7
|
+
data.tar.gz: 11d06b4d5564ccdb5b4016b5bb329e92b67877bab59f1ec541303ec31e79d5017780672c3269f0f314a761b6c47e38add64977556bbf4187baac152c80008f97
|
|
@@ -104,7 +104,7 @@ class RodauthMain < Rodauth::Rails::Auth
|
|
|
104
104
|
# delete_account_on_close? true
|
|
105
105
|
|
|
106
106
|
# Redirect to the app from login and registration pages if already logged in.
|
|
107
|
-
|
|
107
|
+
already_logged_in { redirect login_redirect }
|
|
108
108
|
|
|
109
109
|
<% if defined?(ActionMailer) -%>
|
|
110
110
|
# ==> Emails
|
data/lib/rodauth/rails/app.rb
CHANGED
|
@@ -5,6 +5,9 @@ module Rodauth
|
|
|
5
5
|
module Rails
|
|
6
6
|
# The superclass for creating a Rodauth middleware.
|
|
7
7
|
class App < Roda
|
|
8
|
+
# matches Rodauth's default json_request_content_type_regexp
|
|
9
|
+
JSON_CONTENT_TYPE_REGEXP = /\Aapplication\/(?:vnd\.api\+)?json\b/i
|
|
10
|
+
|
|
8
11
|
plugin :middleware, forward_response_headers: true, next_if_not_found: true
|
|
9
12
|
plugin :hooks
|
|
10
13
|
plugin :pass
|
|
@@ -20,6 +23,9 @@ module Rodauth
|
|
|
20
23
|
# we'll render Rodauth's built-in view templates within Rails layouts
|
|
21
24
|
plugin :render, layout: false unless render == false
|
|
22
25
|
|
|
26
|
+
# configure JSON parser before Rodauth loads it, to avoid Roda's warning
|
|
27
|
+
plugin :json_parser, content_type_regexp: JSON_CONTENT_TYPE_REGEXP if options.fetch(:json, true)
|
|
28
|
+
|
|
23
29
|
plugin :rodauth, auth_class: auth_class, name: name, csrf: false, json: true, render: render, **options, &block
|
|
24
30
|
|
|
25
31
|
# we need to do it after request methods from rodauth have been included
|
|
@@ -81,7 +87,7 @@ module Rodauth
|
|
|
81
87
|
# The Rack input might not be rewindable, so ensure we parse the JSON
|
|
82
88
|
# request body in Rails, and avoid parsing it again in Roda.
|
|
83
89
|
def POST
|
|
84
|
-
if content_type =~
|
|
90
|
+
if content_type =~ JSON_CONTENT_TYPE_REGEXP
|
|
85
91
|
env["roda.json_params"] = scope.rails_request.POST.to_hash
|
|
86
92
|
end
|
|
87
93
|
super
|
|
@@ -51,6 +51,12 @@ module Rodauth
|
|
|
51
51
|
# Calls the controller to verify the authenticity token.
|
|
52
52
|
def rails_check_csrf!
|
|
53
53
|
rails_controller_instance.send(:verify_authenticity_token)
|
|
54
|
+
|
|
55
|
+
# On Rails 8.2+, verify_authenticity_token only marks that forgery
|
|
56
|
+
# protection is enabled, while the actual check is performed here.
|
|
57
|
+
if rails_controller_instance.respond_to?(:verify_request_for_forgery_protection, true)
|
|
58
|
+
rails_controller_instance.send(:verify_request_for_forgery_protection)
|
|
59
|
+
end
|
|
54
60
|
end
|
|
55
61
|
|
|
56
62
|
# Hidden tag with Rails CSRF token inserted into Rodauth templates.
|