Skip to content

Commit

Permalink
feat: add onload js setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Jan 9, 2024
1 parent 276607f commit e5203f9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
5 changes: 1 addition & 4 deletions nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"COOKIE_SECRET": "I_AM_VERY_SECRET",
"CSRF_COOKIE_SECRET": "I_AM_VERY_SECRET_TOO",
"DANGEROUSLY_DISABLE_SECURE_CSRF_COOKIES": "true",
"ORY_SDK_URL": "http://localhost:4433",
"KRATOS_PUBLIC_URL": "http://localhost:4433",
"KRATOS_ADMIN_URL": "http://localhost:4434",
"PORT": "4455"
"ORY_SDK_URL": "http://localhost:4433"
}
}
1 change: 1 addition & 0 deletions views/login.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{{card}}}

{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_login_trigger"}}
{{> js_setup nodes=nodes}}
{{#if extraPartial }}
{{> (extraPartial) }}
{{/if}}
Expand Down
18 changes: 18 additions & 0 deletions views/partials/js_setup.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{! This partial sets up the onclick and onload event handlers for each passkey node.}}
<script type="text/javascript">
// register onclick and onload event handlers for each passkey node.
window.addEventListener("load", () => {
{{#each (onlyNodes nodes "passkey" "")}}
{{#if attributes.onclick}}
// onclick for {{attributes.name}}
document.getElementsByName("{{attributes.name}}").forEach((el) => {
el.addEventListener("click", () => { {{{attributes.onclick}}} })
})
{{/if}}
{{#if attributes.onload}}
// onload for {{attributes.name}}
{{{attributes.onload}}}
{{/if}}
{{/each}}
})
</script>
1 change: 1 addition & 0 deletions views/registration.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{{{card}}}

{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_register_trigger"}}
{{> js_setup nodes=nodes}}
{{#if extraPartial }}
{{> (extraPartial) }}
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion views/settings.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
</div>

{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_register_trigger"}}

{{> js_setup nodes=nodes}}
</div>

0 comments on commit e5203f9

Please sign in to comment.