|
4 | 4 | module Devise |
5 | 5 | module Webauthn |
6 | 6 | module CredentialsHelper |
7 | | - def passkey_creation_form_for(resource_name, form_classes: nil, &block) |
| 7 | + def passkey_creation_form_for(resource_or_resource_name, form_classes: nil, &block) |
8 | 8 | form_with( |
9 | | - url: passkeys_path(resource_name), |
| 9 | + url: passkeys_path(resource_or_resource_name), |
10 | 10 | method: :post, |
11 | 11 | class: form_classes |
12 | 12 | ) do |f| |
13 | | - tag.webauthn_create(data: { options_url: passkey_registration_options_path(resource_name) }) do |
| 13 | + tag.webauthn_create(data: { options_url: passkey_registration_options_path(resource_or_resource_name) }) do |
14 | 14 | concat f.hidden_field(:public_key_credential, data: { webauthn_target: "response" }) |
15 | 15 | concat capture(f, &block) |
16 | 16 | end |
17 | 17 | end |
18 | 18 | end |
19 | 19 |
|
20 | | - def login_with_passkey_button_for(resource_name, text = nil, session_path:, button_classes: nil, |
| 20 | + def login_with_passkey_button_for(resource_or_resource_name, text = nil, session_path:, button_classes: nil, |
21 | 21 | form_classes: nil, &block) |
22 | 22 | form_with( |
23 | 23 | url: session_path, |
24 | 24 | method: :post, |
25 | 25 | class: form_classes |
26 | 26 | ) do |f| |
27 | | - tag.webauthn_get(data: { options_url: passkey_authentication_options_path(resource_name) }) do |
| 27 | + tag.webauthn_get(data: { options_url: passkey_authentication_options_path(resource_or_resource_name) }) do |
28 | 28 | concat f.hidden_field(:public_key_credential, data: { webauthn_target: "response" }) |
29 | 29 |
|
30 | 30 | concat f.button(text, type: "submit", class: button_classes, &block) |
31 | 31 | end |
32 | 32 | end |
33 | 33 | end |
34 | 34 |
|
35 | | - def security_key_creation_form_for(resource_name, form_classes: nil, &block) |
| 35 | + def security_key_creation_form_for(resource_or_resource_name, form_classes: nil, &block) |
36 | 36 | form_with( |
37 | | - url: second_factor_webauthn_credentials_path(resource_name), |
| 37 | + url: second_factor_webauthn_credentials_path(resource_or_resource_name), |
38 | 38 | method: :post, |
39 | 39 | class: form_classes |
40 | 40 | ) do |f| |
41 | 41 | tag.webauthn_create( |
42 | | - data: { options_url: security_key_registration_options_path(resource_name) } |
| 42 | + data: { options_url: security_key_registration_options_path(resource_or_resource_name) } |
43 | 43 | ) do |
44 | 44 | concat f.hidden_field(:public_key_credential, data: { webauthn_target: "response" }) |
45 | 45 | concat capture(f, &block) |
46 | 46 | end |
47 | 47 | end |
48 | 48 | end |
49 | 49 |
|
50 | | - def login_with_security_key_button_for(resource_name, text = nil, button_classes: nil, form_classes: nil, &block) |
| 50 | + def login_with_security_key_button_for(resource_or_resource_name, text = nil, button_classes: nil, |
| 51 | + form_classes: nil, &block) |
51 | 52 | form_with( |
52 | | - url: two_factor_authentication_path(resource_name), |
| 53 | + url: two_factor_authentication_path(resource_or_resource_name), |
53 | 54 | method: :post, |
54 | 55 | class: form_classes |
55 | 56 | ) do |f| |
56 | | - tag.webauthn_get(data: { options_url: security_key_authentication_options_path(resource_name) }) do |
| 57 | + tag.webauthn_get(data: { |
| 58 | + options_url: security_key_authentication_options_path(resource_or_resource_name) |
| 59 | + }) do |
57 | 60 | concat f.hidden_field(:public_key_credential, data: { webauthn_target: "response" }) |
58 | 61 | concat f.button(text, type: "submit", class: button_classes, &block) |
59 | 62 | end |
|
0 commit comments