aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/user_settings/user_settings.js19
-rw-r--r--src/components/user_settings/user_settings.vue26
-rw-r--r--src/i18n/messages.js4
-rw-r--r--src/services/api/api.service.js17
-rw-r--r--src/services/backend_interactor_service/backend_interactor_service.js5
5 files changed, 62 insertions, 9 deletions
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 708d1988..1e7b9b12 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -10,7 +10,10 @@ const UserSettings = {
followsImported: false,
enableFollowsExport: true,
uploading: [ false, false, false, false ],
- previews: [ null, null, null ]
+ previews: [ null, null, null ],
+ deletingAccount: false,
+ deleteAccountConfirmPasswordInput: '',
+ deleteAccountError: false
}
},
components: {
@@ -178,6 +181,20 @@ const UserSettings = {
dismissImported () {
this.followsImported = false
this.followImportError = false
+ },
+ confirmDelete () {
+ this.deletingAccount = true
+ },
+ deleteAccount () {
+ this.$store.state.api.backendInteractor.deleteAccount({password: this.deleteAccountConfirmPasswordInput})
+ .then((res) => {
+ if (res.status === 'success') {
+ this.$store.dispatch('logout')
+ this.$router.push('/main/all')
+ } else {
+ this.deleteAccountError = res.error
+ }
+ })
}
}
}
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 184d158d..ea9763f3 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -67,12 +67,26 @@
</div>
</div>
<div class="setting-item" v-if="enableFollowsExport">
- <h3>{{$t('settings.follow_export')}}</h3>
- <button class="btn btn-default" @click="exportFollows">{{$t('settings.follow_export_button')}}</button>
- </div>
- <div class="setting-item" v-else>
- <h3>{{$t('settings.follow_export_processing')}}</h3>
- </div>
+ <h3>{{$t('settings.follow_export')}}</h3>
+ <button class="btn btn-default" @click="exportFollows">{{$t('settings.follow_export_button')}}</button>
+ </div>
+ <div class="setting-item" v-else>
+ <h3>{{$t('settings.follow_export_processing')}}</h3>
+ </div>
+ <hr>
+ <div class="setting-item">
+ <h3>{{$t('settings.delete_account')}}</h3>
+ <p v-if="!deletingAccount">{{$t('settings.delete_account_description')}}</p>
+ <div v-if="deletingAccount">
+ <p>{{$t('settings.delete_account_instructions')}}</p>
+ <p>{{$t('login.password')}}</p>
+ <input type="password" v-model="deleteAccountConfirmPasswordInput">
+ <button class="btn btn-default" @click="deleteAccount">{{$t('settings.delete_account')}}</button>
+ </div>
+ <p v-if="deleteAccountError !== false">{{$t('settings.delete_account_error')}}</p>
+ <p v-if="deleteAccountError">{{deleteAccountError}}</p>
+ <button class="btn btn-default" v-if="!deletingAccount" @click="confirmDelete">{{$t('general.submit')}}</button>
+ </div>
</div>
</div>
</template>
diff --git a/src/i18n/messages.js b/src/i18n/messages.js
index 43a224ce..19b50272 100644
--- a/src/i18n/messages.js
+++ b/src/i18n/messages.js
@@ -290,6 +290,10 @@ const en = {
import_followers_from_a_csv_file: 'Import follows from a csv file',
follows_imported: 'Follows imported! Processing them will take a while.',
follow_import_error: 'Error importing followers',
+ delete_account: 'Delete Account',
+ delete_account_description: 'Permanantly delete your account and all your messages.',
+ delete_account_instructions: 'Type your password in the input below to confirm account deletion.',
+ delete_account_error: 'There was an issue deleting your account. If this persists please contact your instance administrator.',
follow_export: 'Follow export',
follow_export_processing: 'Processing, you\'ll soon be asked to download your file',
follow_export_button: 'Export your follows to a csv file'
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index f14bfd6d..fd401068 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -30,6 +30,7 @@ const BLOCKING_URL = '/api/blocks/create.json'
const UNBLOCKING_URL = '/api/blocks/destroy.json'
const USER_URL = '/api/users/show.json'
const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import'
+const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account'
import { each, map } from 'lodash'
import 'whatwg-fetch'
@@ -373,6 +374,19 @@ const followImport = ({params, credentials}) => {
.then((response) => response.ok)
}
+const deleteAccount = ({credentials, password}) => {
+ const form = new FormData()
+
+ form.append('password', password)
+
+ return fetch(DELETE_ACCOUNT_URL, {
+ body: form,
+ method: 'POST',
+ headers: authHeaders(credentials)
+ })
+ .then((response) => response.json())
+}
+
const fetchMutes = ({credentials}) => {
const url = '/api/qvitter/mutes.json'
@@ -408,7 +422,8 @@ const apiService = {
updateProfile,
updateBanner,
externalProfile,
- followImport
+ followImport,
+ deleteAccount
}
export default apiService
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index 52b8286b..c5807bed 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -61,6 +61,8 @@ const backendInteractorService = (credentials) => {
const externalProfile = (profileUrl) => apiService.externalProfile({profileUrl, credentials})
const followImport = ({params}) => apiService.followImport({params, credentials})
+ const deleteAccount = ({password}) => apiService.deleteAccount({credentials, password})
+
const backendInteractorServiceInstance = {
fetchStatus,
fetchConversation,
@@ -82,7 +84,8 @@ const backendInteractorService = (credentials) => {
updateBanner,
updateProfile,
externalProfile,
- followImport
+ followImport,
+ deleteAccount
}
return backendInteractorServiceInstance