11<script setup>
22import Head from ' @/pages/layout/Head.vue' ;
3- import { AuthCard , Input , Field , Button , Description } from ' @ui' ;
3+ import { AuthCard , Input , Field , Button , Description , ErrorMessage , Separator } from ' @ui' ;
44import { computed } from ' vue' ;
5- import { Form } from ' @inertiajs/vue3' ;
5+ import { Form , router } from ' @inertiajs/vue3' ;
6+ import { usePasskey } from ' @/composables/passkey' ;
67
7- const props = defineProps ([' method' , ' status' , ' submitUrl' , ' resendUrl' ]);
8+ const props = defineProps ([' method' , ' allowPasskey ' , ' status' , ' submitUrl' , ' resendUrl' , ' passkeyOptionsUrl ' ]);
89const isConfirmingPassword = computed (() => props .method === ' password_confirmation' );
910const isUsingVerificationCode = computed (() => props .method === ' verification_code' );
11+ const isOnlyUsingPasskey = computed (() => props .method === ' passkey' );
12+ const passkey = usePasskey ();
13+
14+ async function confirmWithPasskey () {
15+ await passkey .authenticate (
16+ props .passkeyOptionsUrl ,
17+ props .submitUrl ,
18+ (response ) => router .get (response .redirect )
19+ );
20+ }
1021 </script >
1122
1223<template >
@@ -15,14 +26,12 @@ const isUsingVerificationCode = computed(() => props.method === 'verification_co
1526 <AuthCard
1627 icon =" key"
1728 class =" max-w-md mx-auto mt-8"
18- :title =" isConfirmingPassword ? __('Confirm Your Password') : __('Verification Code')"
19- :description =" isConfirmingPassword
20- ? __('statamic::messages.elevated_session_enter_password')
21- : __('statamic::messages.elevated_session_enter_verification_code')"
29+ :title =" __('Confirm Your Identity')"
30+ :description =" __('statamic::messages.elevated_session_reauthenticate')"
2231 >
2332 <Description v-if =" status" variant =" success" :text =" status" class =" mb-6" />
2433
25- <Form method =" post" :action =" submitUrl" class =" flex flex-col gap-6" v-slot =" { errors }" >
34+ <Form v-if = " !isOnlyUsingPasskey " method =" post" :action =" submitUrl" class =" flex flex-col gap-6" v-slot =" { errors }" >
2635 <Field v-if =" isConfirmingPassword" :label =" __('Password')" :error =" errors.password" >
2736 <Input name =" password" type =" password" viewable autofocus />
2837 </Field >
@@ -43,5 +52,20 @@ const isUsingVerificationCode = computed(() => props.method === 'verification_co
4352 />
4453 </div >
4554 </Form >
55+
56+ <template v-if =" allowPasskey " >
57+ <Separator v-if =" !isOnlyUsingPasskey" variant =" dots" :text =" __('or')" class =" py-3" />
58+
59+ <Button
60+ class =" w-full"
61+ :variant =" isOnlyUsingPasskey ? 'primary' : 'default'"
62+ :text =" __('Confirm with Passkey')"
63+ :icon =" passkey.waiting.value ? null : 'key'"
64+ :disabled =" passkey.waiting.value"
65+ :loading =" passkey.waiting.value"
66+ @click =" confirmWithPasskey"
67+ />
68+ <ErrorMessage v-if =" passkey.error.value" :text =" passkey.error.value" />
69+ </template >
4670 </AuthCard >
4771</template >
0 commit comments