mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-06 15:38:53 -05:00
fix
This commit is contained in:
parent
17b8c60450
commit
0f6d965f54
@ -99,6 +99,46 @@ function popupMiddleNavItems() {
|
|||||||
text: translateString('Change password'),
|
text: translateString('Change password'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
items.push({
|
||||||
|
itemType: 'button',
|
||||||
|
icon: 'delete_forever',
|
||||||
|
text: translateString('Delete account'),
|
||||||
|
buttonAttr: {
|
||||||
|
onClick: (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const confirmed = window.confirm(
|
||||||
|
'Are you sure you want to delete your account? This action cannot be undone and will permanently remove all your data, including your media and playlists.'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (confirmed) {
|
||||||
|
const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]')?.value ||
|
||||||
|
document.cookie.split('; ').find(row => row.startsWith('csrftoken='))?.split('=')[1];
|
||||||
|
|
||||||
|
fetch(`/api/v1/users/${user.username}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': csrfToken,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
|
alert('Your account has been deleted successfully. You will be redirected to the home page.');
|
||||||
|
window.location.href = '/';
|
||||||
|
} else {
|
||||||
|
return response.json().then((data) => {
|
||||||
|
throw new Error(data.detail || 'Failed to delete account.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
alert('Error deleting account: ' + error.message);
|
||||||
|
console.error('Error deleting account:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user