rodauth-rails 2.2.1 → 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: 6ff5f59365d2d0268c0508d9e2d29a47f872746d65c7114d287b753ef36a1cbe
4
- data.tar.gz: 1a6b7ed15c17b5c4e91ab73b0efb191bca57b027b14ab1fde43dc7af8c83aa2a
3
+ metadata.gz: 1ee1baf96e7272819b654ff2ef0153dfc5ff8c8c09547e9b1db848f7daec7949
4
+ data.tar.gz: 58d00e15bde03f30862186d242f9928d17082bf800abf28528782ce492d6081c
5
5
  SHA512:
6
- metadata.gz: b35dce74ceed469ed3015931d026313ed34900ad6d726308f1c80efad6dcf4c3da2fc91024eafcdb3b38b44dd7d23f2e4b7639c7e77411f54aa6c4b5d3f10e7d
7
- data.tar.gz: b3669e57b2f863c6ef0771fe9c157f9b4a19fa8840ed8001e06338017a156b896422702079a18795b06c3ea257a736534be1070b3d66f9506d120304318c886c
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
- # already_logged_in { redirect login_redirect }
107
+ already_logged_in { redirect login_redirect }
108
108
 
109
109
  <% if defined?(ActionMailer) -%>
110
110
  # ==> Emails
@@ -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
@@ -32,7 +38,7 @@ module Rodauth
32
38
  end
33
39
  end
34
40
 
35
- after do
41
+ after do |_res|
36
42
  rails_request.commit_flash
37
43
  end
38
44
 
@@ -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 =~ /json/
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.
@@ -1,5 +1,5 @@
1
1
  module Rodauth
2
2
  module Rails
3
- VERSION = "2.2.1"
3
+ VERSION = "2.2.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić