2019-04-26 23:14:43 +02:00
|
|
|
<template lang="pug">
|
2019-06-07 17:02:33 +02:00
|
|
|
el-card
|
|
|
|
nuxt-link.float-right(to='/')
|
2019-09-07 11:57:54 +02:00
|
|
|
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
|
2019-06-07 17:02:33 +02:00
|
|
|
h5 {{$t('common.settings')}}
|
2019-09-07 11:57:54 +02:00
|
|
|
hr
|
2019-06-07 17:02:33 +02:00
|
|
|
|
2019-09-07 11:57:54 +02:00
|
|
|
el-form(action='/api/user' method='PUT' @submit.native.prevent='change_password' inline label-width='200px')
|
|
|
|
|
|
|
|
el-form-item(:label="$t('settings.change_password')")
|
2019-06-11 17:44:11 +02:00
|
|
|
el-input(v-model='password' type='password')
|
2019-09-07 11:57:54 +02:00
|
|
|
el-button(slot='append' type='success' native-type='submit') {{$t('common.send')}}
|
|
|
|
|
|
|
|
//- allow federation
|
|
|
|
div(v-if='settings.enable_federation')
|
|
|
|
el-form-item(:label="$t('admin.enable_federation')")
|
|
|
|
el-switch(name='reg' v-model='enable_federation')
|
|
|
|
|
|
|
|
el-form-item(v-if='enable_federation' :label="$t('common.username')")
|
|
|
|
el-input(type='text' name='username' v-model='user.username' :suffix='"antani"' :readonly='user.username.length>0')
|
|
|
|
template(slot='suffix') @{{baseurl}}
|
|
|
|
//- el-button(slot='append') {{$t('common.save')}}
|
|
|
|
|
|
|
|
|
2019-06-21 23:52:18 +02:00
|
|
|
|
|
|
|
el-divider {{$t('settings.danger_section')}}
|
|
|
|
p {{$t('settings.remove_account')}}
|
|
|
|
el-button(type='danger' @click='remove_account') {{$t('common.remove')}}
|
2019-04-26 23:14:43 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
2019-06-21 23:52:18 +02:00
|
|
|
import { Message, MessageBox } from 'element-ui'
|
2019-06-11 17:44:11 +02:00
|
|
|
|
2019-04-26 23:14:43 +02:00
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
2019-09-07 11:57:54 +02:00
|
|
|
enable_federation: false,
|
2019-04-26 23:14:43 +02:00
|
|
|
password: '',
|
|
|
|
}
|
|
|
|
},
|
2019-08-07 01:26:14 +02:00
|
|
|
name: 'Settings',
|
|
|
|
head () {
|
|
|
|
return {
|
|
|
|
title: `${this.settings.title} - ${this.$t('common.settings')}`
|
|
|
|
}
|
|
|
|
},
|
2019-06-21 23:52:18 +02:00
|
|
|
async asyncData ({ $axios, params }) {
|
|
|
|
const user = await $axios.$get('/auth/user')
|
|
|
|
user.mastodon_auth = ''
|
|
|
|
return { user }
|
|
|
|
},
|
2019-09-07 11:57:54 +02:00
|
|
|
computed: {
|
|
|
|
...mapState(['settings']),
|
|
|
|
baseurl () {
|
|
|
|
return new URL(this.settings.baseurl).host
|
|
|
|
}
|
|
|
|
},
|
2019-04-26 23:14:43 +02:00
|
|
|
methods: {
|
2019-06-21 23:52:18 +02:00
|
|
|
async change_password () {
|
2019-05-30 12:04:14 +02:00
|
|
|
if (!this.password) return
|
2019-06-07 17:02:33 +02:00
|
|
|
const user_data = { id : this.$auth.user.id, password: this.password }
|
2019-05-30 12:04:14 +02:00
|
|
|
try {
|
2019-06-07 17:02:33 +02:00
|
|
|
const user = await this.$axios.$put('/user', user_data)
|
2019-06-25 01:05:38 +02:00
|
|
|
Message({ message: this.$t('settings.password_updated'), showClose: true, type: 'success' })
|
2019-06-11 17:44:11 +02:00
|
|
|
this.$router.replace('/')
|
2019-05-30 12:04:14 +02:00
|
|
|
} catch (e) {
|
|
|
|
console.log(e)
|
|
|
|
}
|
|
|
|
},
|
2019-06-21 23:52:18 +02:00
|
|
|
async remove_account () {
|
|
|
|
MessageBox.confirm(this.$t('settings.remove_account_confirm'), this.$t('common.confirm'), {
|
|
|
|
confirmButtonText: this.$t('common.ok'),
|
|
|
|
cancelButtonText: this.$t('common.cancel'),
|
|
|
|
type: 'error'
|
|
|
|
}).then( () => {
|
|
|
|
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
|
|
|
})
|
|
|
|
}
|
2019-04-26 23:14:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|