PhaseWeb3-Vue/.laravel-guide/resources/js/Pages/Auth/TwoFactorChallenge.vue
Auron 564087f658
Some checks are pending
Build / build (push) Waiting to run
Update dependancies, move tailwind to V4 (SoftieTechCat)
Initial move to tailwind V4. breaks a couple things visually, a few animations are off, mostly working though.
2025-07-29 20:46:12 -04:00

118 lines
3.2 KiB
Vue

<script setup>
import { useForm, Head } from "@inertiajs/vue3";
import { nextTick, ref } from "vue";
import LayoutGuest from "@/layouts/LayoutGuest.vue";
import SectionFullScreen from "@/components/SectionFullScreen.vue";
import CardBox from "@/components/CardBox.vue";
import FormControl from "@/components/FormControl.vue";
import FormField from "@/components/FormField.vue";
import BaseDivider from "@/components/BaseDivider.vue";
import BaseButton from "@/components/BaseButton.vue";
import FormValidationErrors from "@/components/FormValidationErrors.vue";
import BaseLevel from "@/components/BaseLevel.vue";
const recovery = ref(false);
const form = useForm({
code: "",
recovery_code: "",
});
const recoveryCodeInput = ref(null);
const codeInput = ref(null);
const toggleRecovery = async () => {
recovery.value ^= true;
await nextTick();
if (recovery.value) {
recoveryCodeInput.value?.focus();
form.code = "";
} else {
codeInput.value?.focus();
form.recovery_code = "";
}
};
const submit = () => {
form.post(route("two-factor.login"));
};
</script>
<template>
<LayoutGuest>
<Head title="Two-factor Confirmation" />
<SectionFullScreen v-slot="{ cardClass }" bg="purplePink">
<CardBox :class="cardClass" is-form @submit.prevent="submit">
<FormValidationErrors />
<FormField>
<div class="mb-4 text-sm text-gray-600">
<template v-if="!recovery">
Please confirm access to your account by entering the
authentication code provided by your authenticator application.
</template>
<template v-else>
Please confirm access to your account by entering one of your
emergency recovery codes.
</template>
</div>
</FormField>
<FormField
v-if="!recovery"
label="Code"
label-for="code"
help="Please enter one-time code"
>
<FormControl
id="code"
v-model="form.code"
type="text"
inputmode="numeric"
autofocus
autocomplete="one-time-code"
@set-ref="codeInput = $event"
/>
</FormField>
<FormField
v-else
label="Recovery Code"
label-for="recovery_code"
help="Please enter recovery code"
>
<FormControl
id="recovery_code"
v-model="form.recovery_code"
type="text"
class="mt-1 block w-full"
autocomplete="one-time-code"
@set-ref="recoveryCodeInput = $event"
/>
</FormField>
<BaseDivider />
<BaseLevel>
<BaseButton
type="submit"
color="info"
label="Log in"
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
/>
<button @click.prevent="toggleRecovery">
<template v-if="!recovery"> Use a recovery code </template>
<template v-else> Use an authentication code </template>
</button>
</BaseLevel>
</CardBox>
</SectionFullScreen>
</LayoutGuest>
</template>