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

51 lines
1.5 KiB
Vue
Raw Normal View History

2022-03-15 14:47:07 +01:00
<template>
<form-wrapper :title="$t('auth.webauthn.rename_device')">
<form @submit.prevent="updateCredential" @keydown="form.onKeydown($event)">
<form-field :form="form" fieldName="name" inputType="text" :label="$t('commons.new_name')" autofocus />
2022-09-17 19:31:11 +02:00
<form-buttons
:submitId="'btnEditCredential'"
:isBusy="form.isBusy"
:caption="$t('commons.save')"
:showCancelButton="true"
cancelLandingView="settings.webauthn.devices" />
2022-03-15 14:47:07 +01:00
</form>
</form-wrapper>
</template>
<script>
import Form from './../../../components/Form'
export default {
data() {
return {
form: new Form({
name: this.name,
})
}
},
props: ['credentialId', 'name'],
2022-03-15 14:47:07 +01:00
methods: {
async updateCredential() {
await this.form.patch('/webauthn/credentials/' + this.credentialId + '/name')
2022-03-15 14:47:07 +01:00
if( this.form.errors.any() === false ) {
this.$notify({ type: 'is-success', text: this.$t('auth.webauthn.device_successfully_registered') })
2022-07-07 18:04:04 +02:00
this.$router.push({name: 'settings.webauthn.devices', params: { toRefresh: true }})
2022-03-15 14:47:07 +01:00
}
},
cancelCreation: function() {
2022-07-07 18:04:04 +02:00
this.$router.push({ name: 'settings.webauthn.devices' });
2022-03-15 14:47:07 +01:00
},
},
}
</script>