aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_settings/user_settings.js
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-06-08 13:30:49 +0000
committerlambda <pleromagit@rogerbraun.net>2018-06-08 13:30:49 +0000
commitaf47d51cd14503495c1ee7398ba733ad4c5ed4a4 (patch)
treebf2b0df49756e72800a0f34bd5c26d4fb9beabeb /src/components/user_settings/user_settings.js
parent9b86fc4dcd05a8f63ff564e117f06caf8046be78 (diff)
parente2c5e4eb46143b52ccff21ca0914c5f1b79376fa (diff)
Merge branch 'develop' into 'patch-1'
# Conflicts: # src/i18n/messages.js
Diffstat (limited to 'src/components/user_settings/user_settings.js')
-rw-r--r--src/components/user_settings/user_settings.js71
1 files changed, 70 insertions, 1 deletions
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 25ee1f35..b6026e18 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -8,8 +8,15 @@ const UserSettings = {
followList: null,
followImportError: false,
followsImported: false,
+ enableFollowsExport: true,
uploading: [ false, false, false, false ],
- previews: [ null, null, null ]
+ previews: [ null, null, null ],
+ deletingAccount: false,
+ deleteAccountConfirmPasswordInput: '',
+ deleteAccountError: false,
+ changePasswordInputs: [ '', '', '' ],
+ changedPassword: false,
+ changePasswordError: false
}
},
components: {
@@ -137,6 +144,37 @@ const UserSettings = {
this.uploading[3] = false
})
},
+ /* This function takes an Array of Users
+ * and outputs a file with all the addresses for the user to download
+ */
+ exportPeople (users, filename) {
+ // Get all the friends addresses
+ var UserAddresses = users.map(function (user) {
+ // check is it's a local user
+ if (user && user.is_local) {
+ // append the instance address
+ // eslint-disable-next-line no-undef
+ user.screen_name += '@' + location.hostname
+ }
+ return user.screen_name
+ }).join('\n')
+ // Make the user download the file
+ var fileToDownload = document.createElement('a')
+ fileToDownload.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(UserAddresses))
+ fileToDownload.setAttribute('download', filename)
+ fileToDownload.style.display = 'none'
+ document.body.appendChild(fileToDownload)
+ fileToDownload.click()
+ document.body.removeChild(fileToDownload)
+ },
+ exportFollows () {
+ this.enableFollowsExport = false
+ this.$store.state.api.backendInteractor
+ .fetchFriends({id: this.$store.state.users.currentUser.id})
+ .then((friendList) => {
+ this.exportPeople(friendList, 'friends.csv')
+ })
+ },
followListChange () {
// eslint-disable-next-line no-undef
let formData = new FormData()
@@ -146,6 +184,37 @@ 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
+ }
+ })
+ },
+ changePassword () {
+ const params = {
+ password: this.changePasswordInputs[0],
+ newPassword: this.changePasswordInputs[1],
+ newPasswordConfirmation: this.changePasswordInputs[2]
+ }
+ this.$store.state.api.backendInteractor.changePassword(params)
+ .then((res) => {
+ if (res.status === 'success') {
+ this.changedPassword = true
+ this.changePasswordError = false
+ } else {
+ this.changedPassword = false
+ this.changePasswordError = res.error
+ }
+ })
}
}
}