2FAuth/resources/js_vue3/views/settings/Credentials/Edit.vue

41 lines
1.3 KiB
Vue
Raw Normal View History

2023-10-05 14:09:04 +02:00
<script setup>
import Form from '@/components/formElements/Form'
import { useNotifyStore } from '@/stores/notify'
const router = useRouter()
const notify = useNotifyStore()
const form = reactive(new Form({
name: trans('auth.webauthn.my_device')
}))
const props = defineProps({
credentialId: {
type: String,
default: ''
},
})
function updateCredential() {
form.patch('/webauthn/credentials/' + props.credentialId + '/name')
.then(() => {
notify.info({ text: trans('auth.webauthn.device_successfully_registered') })
router.push({ name: 'settings.webauthn.devices' })
})
}
</script>
<template>
<FormWrapper title="auth.webauthn.rename_device">
<form @submit.prevent="updateCredential" @keydown="form.onKeydown($event)">
2023-10-05 17:05:11 +02:00
<FormField v-model="form.name" fieldName="name" :fieldError="form.errors.get('name')" inputType="text" label="commons.new_name" autofocus />
2023-10-05 14:09:04 +02:00
<FormButtons
:submitId="'btnEditCredential'"
:isBusy="form.isBusy"
:caption="$t('commons.save')"
:showCancelButton="true"
cancelLandingView="settings.webauthn.devices"
/>
</form>
</FormWrapper>
</template>