2019-04-26 23:14:43 +02:00
|
|
|
<template lang="pug">
|
2020-07-29 02:18:46 +02:00
|
|
|
v-main
|
2019-10-22 23:49:21 +02:00
|
|
|
|
2020-01-15 23:51:09 +01:00
|
|
|
p {{$auth.user.email}}
|
|
|
|
//- el-form(action='/api/user' method='PUT' @submit.native.prevent='update_settings' inline label-width='200px')
|
|
|
|
//- el-form-item(:label="$t('settings.change_password')")
|
|
|
|
//- el-input(v-model='password' type='password')
|
|
|
|
//- el-button(type='success' native-type='submit') {{$t('common.save')}}
|
2019-09-11 19:12:24 +02:00
|
|
|
|
2020-07-29 02:18:46 +02:00
|
|
|
p {{$t('settings.danger_section')}}
|
2019-06-21 23:52:18 +02:00
|
|
|
p {{$t('settings.remove_account')}}
|
2020-07-29 02:18:46 +02:00
|
|
|
v-btn(color='danger' @click='remove_account') {{$t('common.remove')}}
|
2019-04-26 23:14:43 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2020-01-15 23:51:09 +01:00
|
|
|
import { mapState } from 'vuex'
|
2019-09-11 19:12:24 +02:00
|
|
|
import url from 'url'
|
2019-06-11 17:44:11 +02:00
|
|
|
|
2019-04-26 23:14:43 +02:00
|
|
|
export default {
|
2019-09-11 19:12:24 +02:00
|
|
|
name: 'Settings',
|
2020-01-15 23:51:09 +01:00
|
|
|
middleware: ['auth'],
|
2019-04-26 23:14:43 +02:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
password: '',
|
2019-09-11 11:58:42 +02:00
|
|
|
user: { }
|
2019-04-26 23:14:43 +02:00
|
|
|
}
|
|
|
|
},
|
2019-09-07 11:57:54 +02:00
|
|
|
computed: {
|
|
|
|
...mapState(['settings']),
|
|
|
|
baseurl () {
|
2019-09-11 11:58:42 +02:00
|
|
|
return url.parse(this.settings.baseurl).host
|
2019-09-07 11:57:54 +02:00
|
|
|
}
|
|
|
|
},
|
2019-04-26 23:14:43 +02:00
|
|
|
methods: {
|
2020-01-15 23:51:09 +01:00
|
|
|
// async change_password () {
|
|
|
|
// if (!this.password) { return }
|
|
|
|
// const user_data = { id: this.$auth.user.id, password: this.password }
|
|
|
|
// try {
|
|
|
|
// await this.$axios.$put('/user', user_data)
|
|
|
|
// Message({ message: this.$t('settings.password_updated'), showClose: true, type: 'success' })
|
|
|
|
// this.$router.replace('/')
|
|
|
|
// } catch (e) {
|
|
|
|
// console.log(e)
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// update_settings () {
|
|
|
|
// MessageBox.confirm(this.$t('settings.update_confirm'),
|
|
|
|
// this.$t('common.confirm'), {
|
|
|
|
// confirmButtonText: this.$t('common.ok'),
|
|
|
|
// cancelButtonText: this.$t('common.cancel'),
|
|
|
|
// type: 'error'
|
|
|
|
// }).then(async () => {
|
|
|
|
// this.user = await this.$axios.$put('/user', { ...this.user, password: this.password })
|
|
|
|
// }).catch(e => {
|
|
|
|
// Message({ message: e, showClose: true, type: 'warning' })
|
|
|
|
// })
|
|
|
|
// },
|
|
|
|
remove_account () {
|
2020-07-31 01:03:19 +02:00
|
|
|
this.$root.$confirm(this.$t('settings.remove_account_confirm'), this.$t('common.confirm'), {
|
2019-06-21 23:52:18 +02:00
|
|
|
type: 'error'
|
2019-09-11 19:12:24 +02:00
|
|
|
}).then(() => {
|
2019-06-21 23:52:18 +02:00
|
|
|
this.$axios.$delete('/user')
|
2019-09-07 11:57:54 +02:00
|
|
|
this.$auth.logout()
|
|
|
|
this.$router.replace('/')
|
2019-06-21 23:52:18 +02:00
|
|
|
})
|
|
|
|
}
|
2020-01-15 23:51:09 +01:00
|
|
|
},
|
|
|
|
head () {
|
|
|
|
return {
|
|
|
|
title: `${this.settings.title} - ${this.$t('common.settings')}`
|
|
|
|
}
|
2019-04-26 23:14:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|