Make sure download link for PDF credentials actually work.

fix #3654
This commit is contained in:
Antoine Nguyen
2025-08-06 09:57:51 +02:00
parent a33c7b68ce
commit 74a5ed9c80
5 changed files with 62 additions and 9 deletions
+3
View File
@@ -17,6 +17,9 @@ export default {
getRandomPassword() {
return repository.get(`${resource}/random_password/`)
},
getCredentials(accountId) {
return repository.get(`credentials/${accountId}/`, { responseType: 'blob' })
},
validate(data) {
return repository.post(`${resource}/validate/`, data)
},
@@ -362,9 +362,9 @@ function getMenuItems(item) {
result.push({
label: element.label,
icon: element.icon,
onClick: () => {
if (element.type === 'download') {
//TODO : downloadFile(element)
onClick: (account) => {
if (element.name === 'get_credentials') {
downloadCredentials(account)
}
fetchIdentities()
},
@@ -438,6 +438,16 @@ async function deleteAccount(account) {
}
}
async function downloadCredentials(account) {
const resp = await accountsApi.getCredentials(account.pk)
const blob = new Blob([resp.data], { type: resp.headers['Content-Type'] })
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = `credentials_${account.pk}.pdf`
link.click()
URL.revokeObjectURL(link.href)
}
function editAlias() {}
function deleteIdentities() {}