rodauth-rails 1.4.1 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +30 -5
  4. data/lib/generators/rodauth/migration/sequel/base.erb +4 -1
  5. data/lib/generators/rodauth/templates/INSTRUCTIONS +11 -1
  6. data/lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb +38 -52
  7. data/lib/generators/rodauth/templates/app/misc/rodauth_main.rb +9 -6
  8. data/lib/generators/rodauth/templates/app/models/account.rb +1 -0
  9. data/lib/generators/rodauth/templates/app/views/rodauth/add_recovery_codes.html.erb +0 -2
  10. data/lib/generators/rodauth/templates/app/views/rodauth/change_login.html.erb +0 -2
  11. data/lib/generators/rodauth/templates/app/views/rodauth/change_password.html.erb +0 -2
  12. data/lib/generators/rodauth/templates/app/views/rodauth/close_account.html.erb +0 -2
  13. data/lib/generators/rodauth/templates/app/views/rodauth/confirm_password.html.erb +0 -2
  14. data/lib/generators/rodauth/templates/app/views/rodauth/create_account.html.erb +0 -2
  15. data/lib/generators/rodauth/templates/app/views/rodauth/email_auth.html.erb +0 -2
  16. data/lib/generators/rodauth/templates/app/views/rodauth/login.html.erb +0 -2
  17. data/lib/generators/rodauth/templates/app/views/rodauth/logout.html.erb +0 -2
  18. data/lib/generators/rodauth/templates/app/views/rodauth/multi_phase_login.html.erb +0 -2
  19. data/lib/generators/rodauth/templates/app/views/rodauth/otp_auth.html.erb +0 -2
  20. data/lib/generators/rodauth/templates/app/views/rodauth/otp_disable.html.erb +0 -2
  21. data/lib/generators/rodauth/templates/app/views/rodauth/otp_setup.html.erb +0 -2
  22. data/lib/generators/rodauth/templates/app/views/rodauth/recovery_auth.html.erb +0 -2
  23. data/lib/generators/rodauth/templates/app/views/rodauth/recovery_codes.html.erb +0 -2
  24. data/lib/generators/rodauth/templates/app/views/rodauth/remember.html.erb +0 -2
  25. data/lib/generators/rodauth/templates/app/views/rodauth/reset_password.html.erb +0 -2
  26. data/lib/generators/rodauth/templates/app/views/rodauth/reset_password_request.html.erb +0 -2
  27. data/lib/generators/rodauth/templates/app/views/rodauth/sms_auth.html.erb +0 -2
  28. data/lib/generators/rodauth/templates/app/views/rodauth/sms_confirm.html.erb +0 -2
  29. data/lib/generators/rodauth/templates/app/views/rodauth/sms_disable.html.erb +0 -2
  30. data/lib/generators/rodauth/templates/app/views/rodauth/sms_request.html.erb +0 -2
  31. data/lib/generators/rodauth/templates/app/views/rodauth/sms_setup.html.erb +0 -2
  32. data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_auth.html.erb +0 -2
  33. data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_disable.html.erb +0 -2
  34. data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_manage.html.erb +0 -2
  35. data/lib/generators/rodauth/templates/app/views/rodauth/unlock_account.html.erb +0 -2
  36. data/lib/generators/rodauth/templates/app/views/rodauth/unlock_account_request.html.erb +0 -2
  37. data/lib/generators/rodauth/templates/app/views/rodauth/verify_account.html.erb +0 -2
  38. data/lib/generators/rodauth/templates/app/views/rodauth/verify_account_resend.html.erb +0 -2
  39. data/lib/generators/rodauth/templates/app/views/rodauth/verify_login_change.html.erb +0 -2
  40. data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_auth.html.erb +0 -2
  41. data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_remove.html.erb +0 -2
  42. data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_setup.html.erb +0 -2
  43. data/lib/generators/rodauth/templates/app/views/rodauth_mailer/verify_login_change.text.erb +2 -2
  44. data/lib/rodauth/rails/feature/render.rb +8 -1
  45. data/lib/rodauth/rails/version.rb +1 -1
  46. data/lib/rodauth/rails.rb +1 -1
  47. data/rodauth-rails.gemspec +1 -1
  48. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4cdb91c64a071bc9cb7895a98e7c07ddc047f1c201b65d255523bda906644dd
4
- data.tar.gz: 3b318fc66015b00e437b77fe650c5cf8c2af9c843b3b4e1f4890237ae9df261b
3
+ metadata.gz: 496b2621170adf123079ae52341d3f6d0b3a120c3fa9f81e1bd26886735c6808
4
+ data.tar.gz: eb1001f7835561714a134649b989c9cb0f09a5091e4b8d009650134f03d60470
5
5
  SHA512:
6
- metadata.gz: ddee77b54a991b2699ed5bc60fd5b1d07cc79fda56be237628f3cac400d848cbab42feaba49bfa27eb63c5fb9709fa64edea1a6b0b2c2b98123df4965d38455f
7
- data.tar.gz: 2b08a11971c028ac6a45110a2265030ed074bbb2d03a46fff58f6ba673476abdae975032d2589dd2121134998e935dcb1ddb4f72056eefd7caa562a34552cd54
6
+ metadata.gz: e6681a10e0d724656c2b27be02a59eebc107f8a13ebf39b5732696da9df6c6631fe8ac23601db12bb568923b339ee790800b96bb3a3c71a9978c8aa02becea9d
7
+ data.tar.gz: e802cd53015dc736395e5cdf1e7f2df3cb0174075da18af1ca5317867e33ad79d695c7d01d22acc2f581d33b578c2da88af0c91259db79bae85183a9316a2334
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 1.5.1 (2022-06-19)
2
+
3
+ * Fix syntax for creating `citext` PG extension in Sequel base migration (@Empact)
4
+
5
+ ## 1.5.0 (2022-06-11)
6
+
7
+ * Remove `content_for` calls from generated view templates (@janko)
8
+
9
+ * Set title instance variable to `@page_title` in generated configuration (@janko)
10
+
11
+ * Set title instance variable on the controller when `title_instance_variable` is set (@HoneyryderChuck)
12
+
13
+ ## 1.4.2 (2022-05-15)
14
+
15
+ * Stop passing email addresses in mailer arguments on verifying login change (@janko)
16
+
17
+ * Extract finding account into a method in the generated mailer (@janko)
18
+
19
+ * Make generated Action Mailer integration work with secondary Rodauth configurations (@janko)
20
+
21
+ * Include `Rodauth::Rails.model` in generated Sequel account model as well (@janko)
22
+
1
23
  ## 1.4.1 (2022-05-08)
2
24
 
3
25
  * Deprecate `Rodauth::Rails::Model` constant (@janko)
data/README.md CHANGED
@@ -321,16 +321,26 @@ $ rails generate rodauth:views webauthn --name admin
321
321
 
322
322
  #### Page titles
323
323
 
324
- The generated view templates use `content_for(:title)` to store Rodauth's page
325
- titles, which you can then retrieve in your layout template to set the page
326
- title:
324
+ The generated configuration sets `title_instance_variable` to make page titles
325
+ available in your views via `@page_title` instance variable, which you can then
326
+ use in your layout:
327
327
 
328
+ ```rb
329
+ # app/misc/rodauth_main.rb
330
+ class RodauthMain < Rodauth::Rails::Auth
331
+ configure do
332
+ # ...
333
+ title_instance_variable :@page_title
334
+ # ...
335
+ end
336
+ end
337
+ ```
328
338
  ```erb
329
339
  <!-- app/views/layouts/application.html.erb -->
330
340
  <!DOCTYPE html>
331
341
  <html>
332
342
  <head>
333
- <title><%= content_for(:title) %></title>
343
+ <title><%= @page_title || "Default title" %></title>
334
344
  <!-- ... -->
335
345
  </head>
336
346
  <body>
@@ -339,6 +349,21 @@ title:
339
349
  </html>
340
350
  ```
341
351
 
352
+ If you're already setting page titles via `content_for`, you can use it in
353
+ generated Rodauth views, giving it the result of the corresponding
354
+ `*_page_title` method:
355
+
356
+ ```erb
357
+ <!-- app/views/rodauth/login.html.erb -->
358
+ <%= content_for :page_title, rodauth.login_page_title %>
359
+ <!-- ... -->
360
+ ```
361
+ ```erb
362
+ <!-- app/views/rodauth/change_password.html.erb -->
363
+ <%= content_for :page_title, rodauth.change_password_page_title %>
364
+ <!-- ... -->
365
+ ```
366
+
342
367
  #### Layout
343
368
 
344
369
  To use different layouts for different Rodauth views, you can compare the
@@ -489,7 +514,7 @@ into the account model, which defines a password attribute and associations for
489
514
  tables used by enabled authentication features.
490
515
 
491
516
  ```rb
492
- class Account < ApplicationRecord
517
+ class Account < ActiveRecord::Base # Sequel::Model
493
518
  include Rodauth::Rails.model # or `Rodauth::Rails.model(:admin)`
494
519
  end
495
520
  ```
@@ -1,5 +1,8 @@
1
1
  <% if db.database_type == :postgres -%>
2
- enable_extension "citext"
2
+ begin
3
+ run "CREATE EXTENSION IF NOT EXISTS citext"
4
+ rescue NoMethodError # migration is being reverted
5
+ end
3
6
 
4
7
  <% end -%>
5
8
  create_table :accounts do
@@ -31,7 +31,17 @@ Depending on your application's configuration some manual setup may be required:
31
31
 
32
32
  * Not required for API-only Applications *
33
33
 
34
- 4. You can copy Rodauth views (for customization) to your app by running:
34
+ 4. Titles for Rodauth pages are available via @page_title instance variable
35
+ by default, you can use it in your layout file:
36
+
37
+ <head>
38
+ <title><%= @page_title || "Default title" %></title>
39
+ ...
40
+ </head>
41
+
42
+ * Not required *
43
+
44
+ 5. You can copy Rodauth views (for customization) to your app by running:
35
45
 
36
46
  rails g rodauth:views
37
47
 
@@ -1,78 +1,64 @@
1
1
  class RodauthMailer < ApplicationMailer
2
- def verify_account(account_id, key)
3
- @email_link = rodauth.verify_account_url(key: email_token(account_id, key))
4
- <% if defined?(ActiveRecord::Railtie) -%>
5
- @account = Account.find(account_id)
6
- <% else -%>
7
- @account = Account.with_pk!(account_id)
8
- <% end -%>
2
+ def verify_account(name = nil, account_id, key)
3
+ @email_link = email_link(name, :verify_account, account_id, key)
4
+ @account = find_account(name, account_id)
9
5
 
10
- mail to: @account.email, subject: rodauth.verify_account_email_subject
6
+ mail to: @account.email, subject: rodauth(name).verify_account_email_subject
11
7
  end
12
8
 
13
- def reset_password(account_id, key)
14
- @email_link = rodauth.reset_password_url(key: email_token(account_id, key))
15
- <% if defined?(ActiveRecord::Railtie) -%>
16
- @account = Account.find(account_id)
17
- <% else -%>
18
- @account = Account.with_pk!(account_id)
19
- <% end -%>
9
+ def reset_password(name = nil, account_id, key)
10
+ @email_link = email_link(name, :reset_password, account_id, key)
11
+ @account = find_account(name, account_id)
20
12
 
21
- mail to: @account.email, subject: rodauth.reset_password_email_subject
13
+ mail to: @account.email, subject: rodauth(name).reset_password_email_subject
22
14
  end
23
15
 
24
- def verify_login_change(account_id, old_login, new_login, key)
25
- @old_login = old_login
26
- @new_login = new_login
27
- @email_link = rodauth.verify_login_change_url(key: email_token(account_id, key))
28
- <% if defined?(ActiveRecord::Railtie) -%>
29
- @account = Account.find(account_id)
30
- <% else -%>
31
- @account = Account.with_pk!(account_id)
32
- <% end -%>
16
+ def verify_login_change(name = nil, account_id, key)
17
+ @email_link = email_link(name, :verify_login_change, account_id, key)
18
+ @account = find_account(name, account_id)
19
+ @new_email = @account.login_change_key.login
33
20
 
34
- mail to: new_login, subject: rodauth.verify_login_change_email_subject
21
+ mail to: @new_email, subject: rodauth(name).verify_login_change_email_subject
35
22
  end
36
23
 
37
- def password_changed(account_id)
38
- <% if defined?(ActiveRecord::Railtie) -%>
39
- @account = Account.find(account_id)
40
- <% else -%>
41
- @account = Account.with_pk!(account_id)
42
- <% end -%>
24
+ def password_changed(name = nil, account_id)
25
+ @account = find_account(name, account_id)
43
26
 
44
- mail to: @account.email, subject: rodauth.password_changed_email_subject
27
+ mail to: @account.email, subject: rodauth(name).password_changed_email_subject
45
28
  end
46
29
 
47
- # def email_auth(account_id, key)
48
- # @email_link = rodauth.email_auth_url(key: email_token(account_id, key))
49
- <% if defined?(ActiveRecord::Railtie) -%>
50
- # @account = Account.find(account_id)
51
- <% else -%>
52
- # @account = Account.with_pk!(account_id)
53
- <% end -%>
30
+ # def email_auth(name = nil, account_id, key)
31
+ # @email_link = email_link(name, :email_auth, account_id, key)
32
+ # @account = find_account(name, account_id)
54
33
 
55
- # mail to: @account.email, subject: rodauth.email_auth_email_subject
34
+ # mail to: @account.email, subject: rodauth(name).email_auth_email_subject
56
35
  # end
57
36
 
58
- # def unlock_account(account_id, key)
59
- # @email_link = rodauth.unlock_account_url(key: email_token(account_id, key))
60
- <% if defined?(ActiveRecord::Railtie) -%>
61
- # @account = Account.find(account_id)
62
- <% else -%>
63
- # @account = Account.with_pk!(account_id)
64
- <% end -%>
37
+ # def unlock_account(name = nil, account_id, key)
38
+ # @email_link = email_link(name, :unlock_account, account_id, key)
39
+ # @account = find_account(name, account_id)
65
40
 
66
- # mail to: @account.email, subject: rodauth.unlock_account_email_subject
41
+ # mail to: @account.email, subject: rodauth(name).unlock_account_email_subject
67
42
  # end
68
43
 
69
44
  private
70
45
 
71
- def email_token(account_id, key)
72
- "#{account_id}_#{rodauth.compute_hmac(key)}"
46
+ def find_account(_name, account_id)
47
+ <% if defined?(ActiveRecord::Railtie) -%>
48
+ Account.find(account_id)
49
+ <% else -%>
50
+ Account.with_pk!(account_id)
51
+ <% end -%>
52
+ end
53
+
54
+ def email_link(name, action, account_id, key)
55
+ instance = rodauth(name)
56
+ instance.instance_variable_set(:@account, { id: account_id })
57
+ instance.instance_variable_set(:"@#{action}_key_value", key)
58
+ instance.public_send(:"#{action}_email_link")
73
59
  end
74
60
 
75
- def rodauth(name = nil)
61
+ def rodauth(name)
76
62
  RodauthApp.rodauth(name).allocate
77
63
  end
78
64
  end
@@ -31,6 +31,9 @@ class RodauthMain < Rodauth::Rails::Auth
31
31
  # Specify the controller used for view rendering and CSRF verification.
32
32
  rails_controller { RodauthController }
33
33
 
34
+ # Set on Rodauth controller with the title of the current page.
35
+ title_instance_variable :@page_title
36
+
34
37
  # Store account status in an integer column without foreign key constraint.
35
38
  account_status_column :status
36
39
 
@@ -56,22 +59,22 @@ class RodauthMain < Rodauth::Rails::Auth
56
59
  # ==> Emails
57
60
  # Use a custom mailer for delivering authentication emails.
58
61
  create_reset_password_email do
59
- RodauthMailer.reset_password(account_id, reset_password_key_value)
62
+ RodauthMailer.reset_password(*self.class.configuration_name, account_id, reset_password_key_value)
60
63
  end
61
64
  create_verify_account_email do
62
- RodauthMailer.verify_account(account_id, verify_account_key_value)
65
+ RodauthMailer.verify_account(*self.class.configuration_name, account_id, verify_account_key_value)
63
66
  end
64
67
  create_verify_login_change_email do |_login|
65
- RodauthMailer.verify_login_change(account_id, verify_login_change_old_login, verify_login_change_new_login, verify_login_change_key_value)
68
+ RodauthMailer.verify_login_change(*self.class.configuration_name, account_id, verify_login_change_key_value)
66
69
  end
67
70
  create_password_changed_email do
68
- RodauthMailer.password_changed(account_id)
71
+ RodauthMailer.password_changed(*self.class.configuration_name, account_id)
69
72
  end
70
73
  # create_email_auth_email do
71
- # RodauthMailer.email_auth(account_id, email_auth_key_value)
74
+ # RodauthMailer.email_auth(*self.class.configuration_name, account_id, email_auth_key_value)
72
75
  # end
73
76
  # create_unlock_account_email do
74
- # RodauthMailer.unlock_account(account_id, unlock_account_key_value)
77
+ # RodauthMailer.unlock_account(*self.class.configuration_name, account_id, unlock_account_key_value)
75
78
  # end
76
79
  send_email do |email|
77
80
  # queue email delivery on the mailer after the transaction commits
@@ -9,6 +9,7 @@ class Account < ApplicationRecord
9
9
  end
10
10
  <% else -%>
11
11
  class Account < Sequel::Model
12
+ include Rodauth::Rails.model
12
13
  plugin :enum
13
14
  enum :status, unverified: 1, verified: 2, closed: 3
14
15
  end
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.add_recovery_codes_page_title %>
2
-
3
1
  <pre id="recovery-codes"><%= rodauth.recovery_codes.map { |s| h(s) }.join("\n\n") %></pre>
4
2
 
5
3
  <% if rodauth.can_add_recovery_codes? %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.change_login_page_title %>
2
-
3
1
  <%= form_with url: rodauth.change_login_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.label "login", rodauth.login_label, class: "form-label" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.change_password_page_title %>
2
-
3
1
  <%= form_with url: rodauth.change_password_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.change_password_requires_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.close_account_page_title %>
2
-
3
1
  <%= form_with url: rodauth.close_account_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.close_account_requires_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.confirm_password_page_title %>
2
-
3
1
  <%= form_with url: rodauth.confirm_password_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.label "password", rodauth.password_label, class: "form-label" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.create_account_page_title %>
2
-
3
1
  <%= form_with url: rodauth.create_account_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.label "login", rodauth.login_label, class: "form-label" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.email_auth_page_title %>
2
-
3
1
  <%= form_with url: rodauth.email_auth_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.submit rodauth.login_button, class: "btn btn-primary" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.login_page_title %>
2
-
3
1
  <%= render "login_form_header" %>
4
2
  <%= render "login_form" %>
5
3
  <%= render "login_form_footer" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.logout_page_title %>
2
-
3
1
  <%= form_with url: rodauth.logout_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.features.include?(:active_sessions) %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.multi_phase_login_page_title %>
2
-
3
1
  <%= render "login_form_header" %>
4
2
  <%== rodauth.render_multi_phase_login_forms %>
5
3
  <%= render "login_form_footer" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.otp_auth_page_title %>
2
-
3
1
  <%= form_with url: rodauth.otp_auth_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.label "otp-auth-code", rodauth.otp_auth_label, class: "form-label" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.otp_disable_page_title %>
2
-
3
1
  <%= form_with url: rodauth.otp_disable_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.two_factor_modifications_require_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.otp_setup_page_title %>
2
-
3
1
  <%= form_with url: rodauth.otp_setup_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <%= form.hidden_field rodauth.otp_setup_param, value: rodauth.otp_user_key, id: "otp-key" %>
5
3
  <%= form.hidden_field rodauth.otp_setup_raw_param, value: rodauth.otp_key, id: "otp-hmac-secret" if rodauth.otp_keys_use_hmac? %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.recovery_auth_page_title %>
2
-
3
1
  <%= form_with url: rodauth.recovery_auth_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.label "recovery-code", rodauth.recovery_codes_label, class: "form-label" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.recovery_codes_page_title %>
2
-
3
1
  <%= form_with url: rodauth.recovery_codes_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.two_factor_modifications_require_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.remember_page_title %>
2
-
3
1
  <%= form_with url: rodauth.remember_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <fieldset class="form-group mb-3">
5
3
  <div class="form-check">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.reset_password_page_title %>
2
-
3
1
  <%= form_with url: rodauth.reset_password_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.label "password", rodauth.password_label, class: "form-label" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.reset_password_request_page_title %>
2
-
3
1
  <%= form_with url: rodauth.reset_password_request_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <%== rodauth.reset_password_explanatory_text %>
5
3
 
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.sms_auth_page_title %>
2
-
3
1
  <%= form_with url: rodauth.sms_auth_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.label "sms-code", rodauth.sms_code_label, class: "form-label" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.sms_confirm_page_title %>
2
-
3
1
  <%= form_with url: rodauth.sms_confirm_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.label "sms-code", rodauth.sms_code_label, class: "form-label" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.sms_disable_page_title %>
2
-
3
1
  <%= form_with url: rodauth.sms_disable_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.two_factor_modifications_require_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.sms_request_page_title %>
2
-
3
1
  <%= form_with url: rodauth.sms_request_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.submit rodauth.sms_request_button, class: "btn btn-primary" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.sms_setup_page_title %>
2
-
3
1
  <%= form_with url: rodauth.sms_setup_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.two_factor_modifications_require_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.two_factor_auth_page_title %>
2
-
3
1
  <ul>
4
2
  <% rodauth.two_factor_auth_links.sort.each do |_, link, text| %>
5
3
  <li><%= link_to text, link %></li>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.two_factor_disable_page_title %>
2
-
3
1
  <%= form_with url: rodauth.two_factor_disable_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.two_factor_modifications_require_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.two_factor_manage_page_title %>
2
-
3
1
  <% if rodauth.two_factor_setup_links.any? %>
4
2
  <%== rodauth.two_factor_setup_heading %>
5
3
 
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.unlock_account_page_title %>
2
-
3
1
  <%= form_with url: rodauth.unlock_account_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <%== rodauth.unlock_account_explanatory_text %>
5
3
 
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.unlock_account_request_page_title %>
2
-
3
1
  <%= form_with url: rodauth.unlock_account_request_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <%= form.hidden_field rodauth.login_param, value: params[rodauth.login_param] %>
5
3
 
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.verify_account_page_title %>
2
-
3
1
  <%= form_with url: rodauth.verify_account_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <% if rodauth.verify_account_set_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.resend_verify_account_page_title %>
2
-
3
1
  <%= form_with url: rodauth.verify_account_resend_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <%== rodauth.verify_account_resend_explanatory_text %>
5
3
 
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.verify_login_change_page_title %>
2
-
3
1
  <%= form_with url: rodauth.verify_login_change_path, method: :post, data: { turbo: false } do |form| %>
4
2
  <div class="form-group mb-3">
5
3
  <%= form.submit rodauth.verify_login_change_button, class: "btn btn-primary" %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.webauthn_auth_page_title %>
2
-
3
1
  <% cred = rodauth.webauth_credential_options_for_get %>
4
2
 
5
3
  <%= 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| %>
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.webauthn_remove_page_title %>
2
-
3
1
  <%= form_with url: rodauth.webauthn_remove_path, method: :post, id: "webauthn-remove-form", data: { turbo: false } do |form| %>
4
2
  <% if rodauth.two_factor_modifications_require_password? %>
5
3
  <div class="form-group mb-3">
@@ -1,5 +1,3 @@
1
- <% content_for :title, rodauth.webauthn_setup_page_title %>
2
-
3
1
  <% cred = rodauth.new_webauthn_credential %>
4
2
 
5
3
  <%= 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| %>
@@ -1,8 +1,8 @@
1
1
  Someone with an account has requested their login be changed to this email address:
2
2
 
3
- Old email: <%= @old_login %>
3
+ Old email: <%= @account.email %>
4
4
 
5
- New email: <%= @new_login %>
5
+ New email: <%= @new_email %>
6
6
 
7
7
  If you did not request this login change, please ignore this message. If you
8
8
  requested this login change, please go to
@@ -8,7 +8,8 @@ module Rodauth
8
8
 
9
9
  # Renders templates with layout. First tries to render a user-defined
10
10
  # template, otherwise falls back to Rodauth's template.
11
- def view(page, *)
11
+ def view(page, title)
12
+ set_title(title)
12
13
  rails_render(action: page.tr("-", "_"), layout: true) ||
13
14
  rails_render(html: super.html_safe, layout: true, formats: :html)
14
15
  end
@@ -50,6 +51,12 @@ module Rodauth
50
51
  html = html.gsub(/<form(.+)>/, '<form\1 data-turbo="false">') if meth == :view
51
52
  html
52
53
  end
54
+
55
+ def set_title(title)
56
+ if title_instance_variable
57
+ rails_controller_instance.instance_variable_set(title_instance_variable, title)
58
+ end
59
+ end
53
60
  end
54
61
  end
55
62
  end
@@ -1,5 +1,5 @@
1
1
  module Rodauth
2
2
  module Rails
3
- VERSION = "1.4.1"
3
+ VERSION = "1.5.1"
4
4
  end
5
5
  end
data/lib/rodauth/rails.rb CHANGED
@@ -16,7 +16,7 @@ module Rodauth
16
16
  @middleware = true
17
17
 
18
18
  class << self
19
- def rodauth(name = nil, query: nil, form: nil, account: nil, **options)
19
+ def rodauth(name = nil, account: nil, **options)
20
20
  auth_class = app.rodauth!(name)
21
21
 
22
22
  unless auth_class.features.include?(:internal_request)
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency "rodauth", "~> 2.23"
21
21
  spec.add_dependency "roda", "~> 3.55"
22
22
  spec.add_dependency "sequel-activerecord_connection", "~> 1.1"
23
- spec.add_dependency "rodauth-model", "~> 0.1"
23
+ spec.add_dependency "rodauth-model", "~> 0.2"
24
24
  spec.add_dependency "tilt"
25
25
  spec.add_dependency "bcrypt"
26
26
 
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: 1.4.1
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-08 00:00:00.000000000 Z
11
+ date: 2022-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.1'
81
+ version: '0.2'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.1'
88
+ version: '0.2'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: tilt
91
91
  requirement: !ruby/object:Gem::Requirement