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