rodauth-rails 1.4.2 → 1.5.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 +8 -0
- data/README.md +29 -4
- data/lib/generators/rodauth/templates/INSTRUCTIONS +11 -1
- data/lib/generators/rodauth/templates/app/misc/rodauth_main.rb +3 -0
- data/lib/generators/rodauth/templates/app/views/rodauth/add_recovery_codes.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/change_login.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/change_password.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/close_account.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/confirm_password.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/create_account.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/email_auth.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/login.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/logout.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/multi_phase_login.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_auth.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_disable.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_setup.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/recovery_auth.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/recovery_codes.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/remember.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/reset_password.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/reset_password_request.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_auth.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_confirm.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_disable.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_request.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_setup.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_auth.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_disable.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_manage.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/unlock_account.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/unlock_account_request.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_account.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_account_resend.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_login_change.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_auth.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_remove.html.erb +0 -2
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_setup.html.erb +0 -2
- data/lib/rodauth/rails/feature/render.rb +8 -1
- data/lib/rodauth/rails/version.rb +1 -1
- data/lib/rodauth/rails.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43e0f2c048024645cb8af7e744042187ded20eeca3f685bdf28a959aebf296e0
|
4
|
+
data.tar.gz: 96d02ad057f315a339bc1cda804f71e19cd629a9cb2ca5c574c515d954692673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c943289cb0c628b37d89fcc6e2a0b22b190ba0e0c0351ffc53c726ac81b0c9f87b0b6e1f929a823724fa1aed70c5b5601279b24df5b54026cb06bb073c3b284c
|
7
|
+
data.tar.gz: afb5b6523b6c440c9b02255b047cf562dd0122a6abb8d49f7c93671981c75935d6a1a9ab1c27a9e8158578a928b70b3705db24760db803acd79abafa58cdc4ce
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 1.5.0 (2022-06-11)
|
2
|
+
|
3
|
+
* Remove `content_for` calls from generated view templates (@janko)
|
4
|
+
|
5
|
+
* Set title instance variable to `@page_title` in generated configuration (@janko)
|
6
|
+
|
7
|
+
* Set title instance variable on the controller when `title_instance_variable` is set (@HoneyryderChuck)
|
8
|
+
|
1
9
|
## 1.4.2 (2022-05-15)
|
2
10
|
|
3
11
|
* Stop passing email addresses in mailer arguments on verifying login change (@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
|
325
|
-
|
326
|
-
|
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><%=
|
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
|
@@ -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.
|
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
|
|
@@ -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
|
|
@@ -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.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.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| %>
|
@@ -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
|
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,
|
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)
|
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
|
+
version: 1.5.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: 2022-
|
11
|
+
date: 2022-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|