rodauth-rails 2.0.2 → 2.1.0

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: f888ea5284cc8afd796f548deec8741f63a474169f419d3f0479cf08bec6fe3b
4
- data.tar.gz: 242e828939f8f96f15661b7f74adae54707ad0025431e46743f8be02879b4ffa
3
+ metadata.gz: 8d16d71f55347be4bf57f7081fda700bfb16c5a9e0007016f191607936e90315
4
+ data.tar.gz: 84febcfd24fca6166f6b5641c252a5c572a769a36535a5d2e2ab508fab6f60b3
5
5
  SHA512:
6
- metadata.gz: d71684eb8b214f061fe589f70110a261bac980546c977834e37cceb53d56636714de08f123ac47d76feb7198814a7607174fafc8fb09be46a04cb9c2e4eb0c31
7
- data.tar.gz: 129e9151b9002e5a58731b24f0d6dd28b20fcab313000d37efec19eb83c4d7d9e501c47dd224f46044318d9c610bab58041169f0adaf789467dc883afb71eb9a
6
+ metadata.gz: 5e01bbfdcba15b5e496dc314b4a249e270564f9d05183f55a16b4b500572fe13b39d15496ef7e6f97e4bb6cd3f88357408ddc140797f92c7c30d8b1a794e6e14
7
+ data.tar.gz: 8c09107331b002024ec55be77b604b9afdc957107d97ddb2aaa9f27146d3f338ae8817bce099be984bc536b2f0acdfa8cee14b0f86ed6997e86344ca28d0cd41
data/README.md CHANGED
@@ -126,18 +126,18 @@ $ rails rodauth:routes
126
126
  ```
127
127
  Routes handled by RodauthApp:
128
128
 
129
- GET|POST /login rodauth.login_path
130
- GET|POST /create-account rodauth.create_account_path
131
- GET|POST /verify-account-resend rodauth.verify_account_resend_path
132
- GET|POST /verify-account rodauth.verify_account_path
133
- GET|POST /change-password rodauth.change_password_path
134
- GET|POST /change-login rodauth.change_login_path
135
- GET|POST /logout rodauth.logout_path
136
- GET|POST /remember rodauth.remember_path
137
- GET|POST /reset-password-request rodauth.reset_password_request_path
138
- GET|POST /reset-password rodauth.reset_password_path
139
- GET|POST /verify-login-change rodauth.verify_login_change_path
140
- GET|POST /close-account rodauth.close_account_path
129
+ login GET|POST /login rodauth.login_path
130
+ create_account GET|POST /create-account rodauth.create_account_path
131
+ verify_account_resend GET|POST /verify-account-resend rodauth.verify_account_resend_path
132
+ verify_account GET|POST /verify-account rodauth.verify_account_path
133
+ change_password GET|POST /change-password rodauth.change_password_path
134
+ change_login GET|POST /change-login rodauth.change_login_path
135
+ logout GET|POST /logout rodauth.logout_path
136
+ remember GET|POST /remember rodauth.remember_path
137
+ reset_password_request GET|POST /reset-password-request rodauth.reset_password_request_path
138
+ reset_password GET|POST /reset-password rodauth.reset_password_path
139
+ verify_login_change GET|POST /verify-login-change rodauth.verify_login_change_path
140
+ close_account GET|POST /close-account rodauth.close_account_path
141
141
  ```
142
142
 
143
143
  Using this information, you can add some basic authentication links to your
@@ -316,10 +316,28 @@ integration:
316
316
  $ rails generate rodauth:mailer
317
317
  ```
318
318
 
319
- This will create a `RodauthMailer`, email templates, and necessary Rodauth
320
- configuration for the features you have enabled. For email links to work, you
321
- need to have `config.action_mailer.default_url_options` set for each
322
- environment.
319
+ This will create a `RodauthMailer` along with email templates, as well as output
320
+ the necessary configuration that you should copy into your auth class:
321
+
322
+ ```rb
323
+ # app/misc/rodauth_main.rb
324
+ class RodauthMain < Rodauth::Rails::Auth
325
+ configure do
326
+ create_verify_account_email do
327
+ RodauthMailer.verify_account(self.class.configuration_name, account_id, verify_account_key_value)
328
+ end
329
+ create_reset_password_email do
330
+ RodauthMailer.reset_password(self.class.configuration_name, account_id, reset_password_key_value)
331
+ end
332
+ create_verify_login_change_email do |_login|
333
+ RodauthMailer.verify_login_change(self.class.configuration_name, account_id, verify_login_change_key_value)
334
+ end
335
+ end
336
+ end
337
+ ```
338
+
339
+ For email links to work, you need to have
340
+ `config.action_mailer.default_url_options` set for each environment.
323
341
 
324
342
  ```rb
325
343
  # config/environments/development.rb
@@ -649,6 +667,7 @@ You can choose to insert the Rodauth middleware somewhere earlier than
649
667
  in front of the Rails router:
650
668
 
651
669
  ```rb
670
+ # config/initializers/rodauth.rb
652
671
  Rodauth::Rails.configure do |config|
653
672
  config.middleware = false # disable auto-insertion
654
673
  end
@@ -656,6 +675,17 @@ end
656
675
  Rails.configuration.middleware.insert_before AnotherMiddleware, Rodauth::Rails::Middleware
657
676
  ```
658
677
 
678
+ ### Skipping Tilt
679
+
680
+ Rodauth uses the [Tilt] gem to render built-in view & email templates. If you don't want to have Tilt as a dependency, you can disable it, provided that you've imported all view & email templates into your app:
681
+
682
+ ```rb
683
+ # config/initializers/rodauth.rb
684
+ Rodauth::Rails.configure do |config|
685
+ config.tilt = false # skip loading Tilt gem
686
+ end
687
+ ```
688
+
659
689
  ## How it works
660
690
 
661
691
  ### Rack middleware
@@ -799,3 +829,4 @@ conduct](CODE_OF_CONDUCT.md).
799
829
  [library]: https://github.com/jeremyevans/rodauth#label-Using+Rodauth+as+a+Library
800
830
  [restoring defaults]: https://github.com/janko/rodauth-rails/wiki/Restoring-Rodauth-Defaults
801
831
  [Rack::Attack]: https://github.com/rack/rack-attack
832
+ [Tilt]: https://github.com/jeremyevans/tilt
@@ -40,18 +40,18 @@ module Rodauth
40
40
 
41
41
  def add_gems
42
42
  if activerecord? && !sequel?
43
- gem "sequel-activerecord_connection", "~> 2.0", comment: "Enables Sequel to use Active Record's database connection"
44
- gem "after_commit_everywhere", "~> 1.1", comment: "Required for Sequel's transaction hooks to work in all cases (on Active Record < 7.2)" if ActiveRecord.version < Gem::Version.new("7.2")
43
+ gem "sequel-activerecord_connection", "~> 2.0", require: false, comment: "Enables Sequel to use Active Record's database connection"
44
+ gem "after_commit_everywhere", "~> 1.1", require: false, comment: "Required for Sequel's transaction hooks to work in all cases (on Active Record < 7.2)" if ActiveRecord.version < Gem::Version.new("7.2")
45
45
  end
46
46
  if argon2?
47
- gem "argon2", "~> 2.3", comment: "Used by Rodauth for password hashing"
47
+ gem "argon2", "~> 2.3", require: false, comment: "Used by Rodauth for password hashing"
48
48
  else
49
- gem "bcrypt", "~> 3.1", comment: "Used by Rodauth for password hashing"
49
+ gem "bcrypt", "~> 3.1", require: false, comment: "Used by Rodauth for password hashing"
50
50
  end
51
51
  if jwt?
52
- gem "jwt", "~> 2.9", comment: "Used by Rodauth for JWT support"
52
+ gem "jwt", "~> 2.9", require: false, comment: "Used by Rodauth for JWT support"
53
53
  end
54
- gem "tilt", "~> 2.4", comment: "Used by Rodauth for rendering built-in view and email templates"
54
+ gem "tilt", "~> 2.4", require: false, comment: "Used by Rodauth for rendering built-in view and email templates"
55
55
  end
56
56
 
57
57
  def create_rodauth_controller
@@ -1,3 +1,5 @@
1
1
  Rodauth::Rails.configure do |config|
2
2
  config.app = "RodauthApp"
3
+ # config.middleware = false # disable auto-insertion of Rodauth middleware
4
+ # config.tilt = false # skip loading Tilt gem for rendering built-in templates
3
5
  end
@@ -9,7 +9,7 @@ module Rodauth
9
9
  plugin :hooks
10
10
  plugin :pass
11
11
 
12
- def self.configure(*args, **options, &block)
12
+ def self.configure(*args, render: Rodauth::Rails.tilt?, **options, &block)
13
13
  auth_class = args.shift if args[0].is_a?(Class)
14
14
  auth_class ||= Class.new(Rodauth::Rails::Auth)
15
15
  name = args.shift if args[0].is_a?(Symbol)
@@ -17,9 +17,9 @@ module Rodauth
17
17
  fail ArgumentError, "need to pass optional Rodauth::Auth subclass and optional configuration name" if args.any?
18
18
 
19
19
  # we'll render Rodauth's built-in view templates within Rails layouts
20
- plugin :render, layout: false unless options[:render] == false
20
+ plugin :render, layout: false unless render == false
21
21
 
22
- plugin :rodauth, auth_class: auth_class, name: name, csrf: false, flash: false, json: true, **options, &block
22
+ plugin :rodauth, auth_class: auth_class, name: name, csrf: false, flash: false, json: true, render: render, **options, &block
23
23
 
24
24
  # we need to do it after request methods from rodauth have been included
25
25
  self::RodaRequest.include RequestMethods
@@ -18,6 +18,7 @@ module Rodauth
18
18
  verbs = route_verbs(route_name)
19
19
 
20
20
  [
21
+ route_name.to_s,
21
22
  verbs.join("|"),
22
23
  "#{rodauth.prefix}#{path}",
23
24
  "rodauth#{configuration_name && "(:#{configuration_name})"}.#{route_name}_path",
@@ -28,7 +29,7 @@ module Rodauth
28
29
  padding = routes.transpose.map { |string| string.map(&:length).max }
29
30
 
30
31
  output_lines = routes.map do |columns|
31
- [columns[0].ljust(padding[0]), columns[1].ljust(padding[1]), columns[2]].join(" ")
32
+ [columns[0].rjust(padding[0]), columns[1].ljust(padding[1]), columns[2].ljust(padding[2]), columns[3]].join(" ")
32
33
  end
33
34
 
34
35
  puts "\n #{output_lines.join("\n ")}"
@@ -67,4 +68,3 @@ module Rodauth
67
68
  end
68
69
  end
69
70
  end
70
-
@@ -1,5 +1,5 @@
1
1
  module Rodauth
2
2
  module Rails
3
- VERSION = "2.0.2"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
data/lib/rodauth/rails.rb CHANGED
@@ -14,6 +14,7 @@ module Rodauth
14
14
 
15
15
  @app = nil
16
16
  @middleware = true
17
+ @tilt = true
17
18
 
18
19
  class << self
19
20
  def lib(**options, &block)
@@ -82,6 +83,7 @@ module Rodauth
82
83
 
83
84
  attr_writer :app
84
85
  attr_writer :middleware
86
+ attr_writer :tilt
85
87
 
86
88
  def app
87
89
  fail Rodauth::Rails::Error, "app was not configured" unless @app
@@ -92,6 +94,10 @@ module Rodauth
92
94
  def middleware?
93
95
  @middleware
94
96
  end
97
+
98
+ def tilt?
99
+ @tilt
100
+ end
95
101
  end
96
102
  end
97
103
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.files = Dir["README.md", "LICENSE.txt", "lib/**/*", "*.gemspec"]
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency "railties", ">= 5.0", "< 8.1"
19
+ spec.add_dependency "railties", ">= 5.1", "< 8.1"
20
20
  spec.add_dependency "rodauth", "~> 2.36"
21
21
  spec.add_dependency "roda", "~> 3.76"
22
22
  spec.add_dependency "rodauth-model", "~> 0.2"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-19 00:00:00.000000000 Z
10
+ date: 2025-03-19 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -16,7 +15,7 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '5.0'
18
+ version: '5.1'
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
21
  version: '8.1'
@@ -26,7 +25,7 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- version: '5.0'
28
+ version: '5.1'
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
31
  version: '8.1'
@@ -350,7 +349,6 @@ homepage: https://github.com/janko/rodauth-rails
350
349
  licenses:
351
350
  - MIT
352
351
  metadata: {}
353
- post_install_message:
354
352
  rdoc_options: []
355
353
  require_paths:
356
354
  - lib
@@ -365,8 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
365
363
  - !ruby/object:Gem::Version
366
364
  version: '0'
367
365
  requirements: []
368
- rubygems_version: 3.5.22
369
- signing_key:
366
+ rubygems_version: 3.6.2
370
367
  specification_version: 4
371
368
  summary: Provides Rails integration for Rodauth authentication framework.
372
369
  test_files: []