mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-02 12:13:54 +01:00
Updated dev reqs
This commit is contained in:
@@ -16,4 +16,7 @@ export default {
|
||||
beginFidoRegistration() {
|
||||
return repository.post('/fido/registration/begin/')
|
||||
},
|
||||
endFidoRegistration(data) {
|
||||
return repository.post('/fido/registration/end/', data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
}}
|
||||
</div>
|
||||
<template v-if="browserCapable">
|
||||
<v-text-field v-model="name" />
|
||||
<v-btn color="success" :loading="registrationLoading" @click="startFidoRegistration">
|
||||
{{ $gettext('Add WebAuthN device') }}
|
||||
</v-btn>
|
||||
<v-form ref="fidoForm" @submit.prevent="startFidoRegistration">
|
||||
<v-text-field v-model="name" :rules="[rules.required]"/>
|
||||
<v-btn color="success" type="submit" :loading="registrationLoading">
|
||||
{{ $gettext('Add WebAuthN device') }}
|
||||
</v-btn>
|
||||
</v-form>
|
||||
</template>
|
||||
<template v-else>
|
||||
<v-alert type="error">
|
||||
@@ -34,6 +36,7 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import authApi from '@/api/auth.js'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import rules from '@/plugins/rules.js'
|
||||
|
||||
const { $gettext } = useGettext()
|
||||
|
||||
@@ -41,13 +44,22 @@ const name = ref()
|
||||
const registrationLoading = ref(false)
|
||||
const creationOption = ref()
|
||||
const browserCapable = !!(navigator.credentials && navigator.credentials.create && navigator.credentials.get && window.PublicKeyCredential)
|
||||
const fidoForm = ref()
|
||||
|
||||
async function startFidoRegistration() {
|
||||
const { valid } = await fidoForm.value.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
if (creationOption.value) {
|
||||
navigator.credentials.create({...creationOption.value})
|
||||
.then(function (attestation) {
|
||||
const result = createResponseToJSON(attestation)
|
||||
result.name = name.value
|
||||
console.log(result)
|
||||
authApi.endFidoRegistration(result).then((resp) => {
|
||||
console.log(resp)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user