mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-27 11:24:28 +01:00
Fido fixes and updated changelog
Rmeoved enabled parameter to fido objects for more simplicity, added logout redirect to frontend app, added edition to fido objects name through the frontend
This commit is contained in:
@@ -25,4 +25,7 @@ export default {
|
||||
deleteFido(id) {
|
||||
return repository.delete(`/fido/${id}/`)
|
||||
},
|
||||
editFido(id, data) {
|
||||
return repository.put(`/fido/${id}/`, data)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -92,11 +92,6 @@
|
||||
:label="$gettext('name')"
|
||||
:rules="[rules.required]"
|
||||
/>
|
||||
<v-switch
|
||||
v-model="editEnabled"
|
||||
:label="$gettext('enabled')"
|
||||
color="principal"
|
||||
/>
|
||||
</v-form>
|
||||
</ConfirmDialog>
|
||||
<v-dialog v-model="showBackupTokenDialog" max-width="800px" persistent>
|
||||
@@ -139,14 +134,12 @@ const headers = [
|
||||
{ title: $gettext('Added On'), key: 'added_on' },
|
||||
{ title: $gettext('Last Used'), key: 'last_used' },
|
||||
{ title: $gettext('Use count'), key: 'use_count' },
|
||||
{ title: $gettext('Enabled'), key: 'enabled' },
|
||||
{ title: $gettext('Actions'), key: 'actions' },
|
||||
]
|
||||
const confirmDeletion = ref()
|
||||
const confirmEdition = ref()
|
||||
const editForm = ref()
|
||||
const editName = ref('')
|
||||
const editEnabled = ref(false)
|
||||
const tokens = ref()
|
||||
const showBackupTokenDialog = ref(false)
|
||||
|
||||
@@ -159,21 +152,18 @@ async function startFidoRegistration() {
|
||||
const creationOption = await authApi.beginFidoRegistration()
|
||||
if (creationOption) {
|
||||
const options = parseCreationOptionsFromJSON(creationOption.data)
|
||||
try {
|
||||
const device = await create(options)
|
||||
const result = device.toJSON()
|
||||
result.name = name.value
|
||||
authStore.addFidoCred(result).then((res) => {
|
||||
if (res.status === 200) {
|
||||
tokens.value = res.data.tokens
|
||||
showBackupTokenDialog.value = true
|
||||
}
|
||||
})
|
||||
fidoForm.value.reset()
|
||||
} catch {
|
||||
registrationLoading.value = false
|
||||
return
|
||||
}
|
||||
const device = await create(options)
|
||||
const result = device.toJSON()
|
||||
result.name = name.value
|
||||
authStore.addFidoCred(result).then((res) => {
|
||||
if (res.status === 200) {
|
||||
tokens.value = res.data.tokens
|
||||
showBackupTokenDialog.value = true
|
||||
}
|
||||
})
|
||||
fidoForm.value.reset()
|
||||
registrationLoading.value = false
|
||||
return
|
||||
}
|
||||
registrationLoading.value = false
|
||||
}
|
||||
@@ -205,7 +195,6 @@ async function checkForm() {
|
||||
|
||||
async function editCred(cred) {
|
||||
editName.value = cred.name
|
||||
editEnabled.value = cred.enabled
|
||||
|
||||
const result = await confirmEdition.value.open(
|
||||
$gettext('Edition'),
|
||||
@@ -219,9 +208,8 @@ async function editCred(cred) {
|
||||
if (!result) {
|
||||
return
|
||||
}
|
||||
|
||||
data = { name: editName.value, enabled: editEnabled.value }
|
||||
//TODO : send it !
|
||||
const data = { name: editName.value }
|
||||
await authStore.editFidoCred(cred.id, data)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
@@ -21,6 +21,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
authority: config.OAUTH_AUTHORITY_URL,
|
||||
client_id: config.OAUTH_CLIENT_ID,
|
||||
redirect_uri: config.OAUTH_REDIRECT_URI,
|
||||
post_logout_redirect_uri: config.OAUTH_POST_REDIRECT_URI,
|
||||
response_type: 'code',
|
||||
scope: 'openid read write',
|
||||
automaticSilentRenew: true,
|
||||
@@ -71,6 +72,18 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
})
|
||||
}
|
||||
|
||||
async function editFidoCred(id, data) {
|
||||
return authApi.editFido(id, data).then((res) => {
|
||||
for (const i = 0; i < fidoCreds.value.length; i++) {
|
||||
if (fidoCreds.value[i].id === id) {
|
||||
fidoCreds.value[i] = res.data
|
||||
break
|
||||
}
|
||||
}
|
||||
return res
|
||||
})
|
||||
}
|
||||
|
||||
function getAccessToken() {
|
||||
return manager.getUser().then((user) => {
|
||||
if (!user) {
|
||||
@@ -172,6 +185,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
getFidoCreds,
|
||||
addFidoCred,
|
||||
deleteFidoCreds,
|
||||
editFidoCred,
|
||||
initialize,
|
||||
login,
|
||||
$reset,
|
||||
|
||||
Reference in New Issue
Block a user