diff --git a/dashboard/src/models/ProfileModel.js b/dashboard/src/models/ProfileModel.js index 7da9debe5..6326a307e 100644 --- a/dashboard/src/models/ProfileModel.js +++ b/dashboard/src/models/ProfileModel.js @@ -142,6 +142,19 @@ function create() { return null; }, + async unsetAvatar() { + let error, result; + try { + result = await fetcher.del(`${API_ORIGIN}/api/v1/profile/avatar`, null, { access_token: accessToken }); + } catch (e) { + error = e; + } + + if (error) return error; + if (result.status !== 204) return result; + + return null; + }, async setBackgroundImage(file) { const fd = new FormData(); if (file) fd.append('backgroundImage', file); diff --git a/dashboard/src/views/ProfileView.vue b/dashboard/src/views/ProfileView.vue index 47674f9cb..bbc9d438a 100644 --- a/dashboard/src/views/ProfileView.vue +++ b/dashboard/src/views/ProfileView.vue @@ -80,6 +80,11 @@ async function onAvatarSubmit(file) { await refreshProfile(); } +async function onAvatarUnset() { + await profileModel.unsetAvatar(); + await refreshProfile(); +} + async function onPasswordChange() { passwordChangeDialog.value.open(); } @@ -211,7 +216,7 @@ onMounted(async () => {