2023-12-09 14:47:03 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<h3 class="font-semibold text-2xl text-gray-900">Danger zone</h3>
|
|
|
|
<p class="text-gray-600 text-sm mt-2">
|
|
|
|
This will permanently delete your entire account. All your forms, submissions and workspaces will be deleted.
|
|
|
|
<span class="text-red-500">
|
|
|
|
This cannot be undone.
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<!-- Submit Button -->
|
|
|
|
<v-button :loading="loading" class="mt-4" color="red" @click="alertConfirm('Do you really want to delete your account?',deleteAccount)">
|
|
|
|
Delete account
|
|
|
|
</v-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
scrollToTop: false,
|
|
|
|
|
|
|
|
setup () {
|
|
|
|
const authStore = useAuthStore()
|
|
|
|
return {
|
|
|
|
authStore
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data: () => ({
|
|
|
|
metaTitle: 'Account',
|
2023-12-24 19:19:59 +00:00
|
|
|
form: useForm({
|
2023-12-09 14:47:03 +00:00
|
|
|
identifier: ''
|
|
|
|
}),
|
|
|
|
loading: false
|
|
|
|
}),
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async deleteAccount () {
|
|
|
|
this.loading = true
|
|
|
|
axios.delete('/api/user').then(async (response) => {
|
|
|
|
this.loading = false
|
2023-12-31 11:39:01 +00:00
|
|
|
useAlert().success(response.data.message)
|
2023-12-09 14:47:03 +00:00
|
|
|
// Log out the user.
|
|
|
|
await this.authStore.logout()
|
|
|
|
|
|
|
|
// Redirect to login.
|
|
|
|
this.$router.push({ name: 'login' })
|
|
|
|
}).catch((error) => {
|
2023-12-31 11:39:01 +00:00
|
|
|
useAlert().error(error.response.data.message)
|
2023-12-09 14:47:03 +00:00
|
|
|
this.loading = false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|