2020-04-17 22:46:50 +02:00
|
|
|
<template>
|
2020-06-15 10:44:47 +02:00
|
|
|
<div
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="{ 'is-loading': passwordUpdateService.loading || emailUpdateService.loading || totpService.loading }"
|
|
|
|
class="loader-container is-max-width-desktop">
|
2021-06-23 17:23:51 +02:00
|
|
|
<!-- General -->
|
2021-06-24 01:24:57 +02:00
|
|
|
<card :title="$t('user.settings.general.title')" class="general-settings">
|
2021-06-23 17:23:51 +02:00
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="newName">{{ $t('user.settings.general.name') }}</label>
|
2021-06-23 17:23:51 +02:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
@keyup.enter="updateSettings"
|
|
|
|
class="input"
|
|
|
|
id="newName"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.settings.general.newName')"
|
2021-06-23 17:23:51 +02:00
|
|
|
type="text"
|
|
|
|
v-model="settings.name"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-17 23:21:46 +02:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">
|
|
|
|
{{ $t('user.settings.general.defaultList') }}
|
|
|
|
</label>
|
|
|
|
<list-search v-model="defaultList"/>
|
|
|
|
</div>
|
2021-06-23 17:23:51 +02:00
|
|
|
<div class="field">
|
|
|
|
<label class="checkbox">
|
|
|
|
<input type="checkbox" v-model="settings.emailRemindersEnabled"/>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.general.emailReminders') }}
|
2021-06-23 17:23:51 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="checkbox">
|
|
|
|
<input type="checkbox" v-model="settings.overdueTasksRemindersEnabled"/>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.general.overdueReminders') }}
|
2021-06-23 17:23:51 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="checkbox">
|
|
|
|
<input type="checkbox" v-model="settings.discoverableByName"/>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.general.discoverableByName') }}
|
2021-06-23 17:23:51 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="checkbox">
|
|
|
|
<input type="checkbox" v-model="settings.discoverableByEmail"/>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.general.discoverableByEmail') }}
|
2021-06-23 17:23:51 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="checkbox">
|
|
|
|
<input type="checkbox" v-model="playSoundWhenDone"/>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.general.playSoundWhenDone') }}
|
2021-06-23 17:23:51 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="is-flex is-align-items-center">
|
|
|
|
<span>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.general.weekStart') }}
|
2021-06-23 17:23:51 +02:00
|
|
|
</span>
|
|
|
|
<div class="select ml-2">
|
|
|
|
<select v-model.number="settings.weekStart">
|
2021-06-24 01:24:57 +02:00
|
|
|
<option value="0">{{ $t('user.settings.general.weekStartSunday') }}</option>
|
|
|
|
<option value="1">{{ $t('user.settings.general.weekStartMonday') }}</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="is-flex is-align-items-center">
|
|
|
|
<span>
|
|
|
|
{{ $t('user.settings.general.language') }}
|
|
|
|
</span>
|
|
|
|
<div class="select ml-2">
|
2021-09-05 13:31:53 +02:00
|
|
|
<select v-model="language">
|
|
|
|
<option :value="lang.code" v-for="lang in availableLanguages" :key="lang.code">{{ lang.title }}</option>
|
2021-06-23 17:23:51 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<x-button
|
|
|
|
:loading="userSettingsService.loading"
|
|
|
|
@click="updateSettings()"
|
|
|
|
class="is-fullwidth mt-4"
|
|
|
|
>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.save') }}
|
2021-06-23 17:23:51 +02:00
|
|
|
</x-button>
|
|
|
|
</card>
|
|
|
|
|
|
|
|
<!-- Avatar -->
|
|
|
|
<avatar-settings/>
|
|
|
|
|
2020-06-15 18:47:17 +02:00
|
|
|
<!-- Password update -->
|
2021-06-24 01:24:57 +02:00
|
|
|
<card :title="$t('user.settings.newPasswordTitle')">
|
2021-01-17 18:57:57 +01:00
|
|
|
<form @submit.prevent="updatePassword()">
|
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="newPassword">{{ $t('user.settings.newPassword') }}</label>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
@keyup.enter="updatePassword"
|
|
|
|
class="input"
|
|
|
|
id="newPassword"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
2021-01-17 18:57:57 +01:00
|
|
|
type="password"
|
|
|
|
v-model="passwordUpdate.newPassword"/>
|
2020-04-17 22:46:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="newPasswordConfirm">{{ $t('user.settings.newPasswordConfirm') }}</label>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
@keyup.enter="updatePassword"
|
|
|
|
class="input"
|
|
|
|
id="newPasswordConfirm"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
2021-01-17 18:57:57 +01:00
|
|
|
type="password"
|
|
|
|
v-model="passwordConfirm"/>
|
2020-04-17 22:46:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="currentPassword">{{ $t('user.settings.currentPassword') }}</label>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
@keyup.enter="updatePassword"
|
|
|
|
class="input"
|
|
|
|
id="currentPassword"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.settings.currentPasswordPlaceholder')"
|
2021-01-17 18:57:57 +01:00
|
|
|
type="password"
|
|
|
|
v-model="passwordUpdate.oldPassword"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2020-06-15 18:47:17 +02:00
|
|
|
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button
|
|
|
|
:loading="passwordUpdateService.loading"
|
|
|
|
@click="updatePassword()"
|
|
|
|
class="is-fullwidth mt-4">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.save') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
|
|
|
</card>
|
|
|
|
|
|
|
|
<!-- Update E-Mail -->
|
2021-06-24 01:24:57 +02:00
|
|
|
<card :title="$t('user.settings.updateEmailTitle')">
|
2021-01-17 18:57:57 +01:00
|
|
|
<form @submit.prevent="updateEmail()">
|
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="newEmail">{{ $t('user.settings.updateEmailNew') }}</label>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
@keyup.enter="updateEmail"
|
|
|
|
class="input"
|
|
|
|
id="newEmail"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.auth.emailPlaceholder')"
|
2021-01-17 18:57:57 +01:00
|
|
|
type="email"
|
|
|
|
v-model="emailUpdate.newEmail"/>
|
2020-12-19 01:12:30 +01:00
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
</div>
|
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="currentPasswordEmail">{{ $t('user.settings.currentPassword') }}</label>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
@keyup.enter="updateEmail"
|
|
|
|
class="input"
|
2021-04-18 19:42:27 +02:00
|
|
|
id="currentPasswordEmail"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.settings.currentPasswordPlaceholder')"
|
2021-01-17 18:57:57 +01:00
|
|
|
type="password"
|
|
|
|
v-model="emailUpdate.password"/>
|
2020-12-19 01:12:30 +01:00
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
2020-11-21 22:25:00 +01:00
|
|
|
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button
|
|
|
|
:loading="emailUpdateService.loading"
|
|
|
|
@click="updateEmail()"
|
|
|
|
class="is-fullwidth mt-4">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.save') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
|
|
|
</card>
|
|
|
|
|
2020-06-15 18:47:17 +02:00
|
|
|
<!-- TOTP -->
|
2021-06-24 01:24:57 +02:00
|
|
|
<card :title="$t('user.settings.totp.title')" v-if="totpEnabled">
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button
|
|
|
|
:loading="totpService.loading"
|
|
|
|
@click="totpEnroll()"
|
|
|
|
v-if="!totpEnrolled && totp.secret === ''">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.totp.enroll') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
|
|
|
<template v-else-if="totp.secret !== '' && !totp.enabled">
|
|
|
|
<p>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.totp.finishSetupPart1') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
<strong>{{ totp.secret }}</strong><br/>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.totp.finishSetupPart2') }}
|
2020-04-18 01:46:07 +02:00
|
|
|
</p>
|
2021-01-17 18:57:57 +01:00
|
|
|
<p>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.totp.scanQR') }}<br/>
|
2021-01-17 18:57:57 +01:00
|
|
|
<img :src="totpQR" alt=""/>
|
|
|
|
</p>
|
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="totpConfirmPasscode">{{ $t('user.settings.totp.passcode') }}</label>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
@keyup.enter="totpConfirm()"
|
|
|
|
class="input"
|
|
|
|
id="totpConfirmPasscode"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.settings.totp.passcodePlaceholder')"
|
2021-01-17 18:57:57 +01:00
|
|
|
type="text"
|
|
|
|
v-model="totpConfirmPasscode"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-06-24 01:24:57 +02:00
|
|
|
<x-button @click="totpConfirm()">{{ $t('misc.confirm') }}</x-button>
|
2021-01-17 18:57:57 +01:00
|
|
|
</template>
|
|
|
|
<template v-else-if="totp.secret !== '' && totp.enabled">
|
|
|
|
<p>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.totp.setupSuccess') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</p>
|
|
|
|
<p v-if="!totpDisableForm">
|
2021-06-24 01:24:57 +02:00
|
|
|
<x-button @click="totpDisableForm = true" class="is-danger">{{ $t('misc.disable') }}</x-button>
|
2021-01-17 18:57:57 +01:00
|
|
|
</p>
|
|
|
|
<div v-if="totpDisableForm">
|
2020-04-18 01:46:07 +02:00
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="currentPassword">{{ $t('user.settings.totp.enterPassword') }}</label>
|
2020-04-18 01:46:07 +02:00
|
|
|
<div class="control">
|
2020-06-15 10:44:47 +02:00
|
|
|
<input
|
2021-01-17 18:57:57 +01:00
|
|
|
@keyup.enter="totpDisable"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="input"
|
2021-01-17 18:57:57 +01:00
|
|
|
id="currentPassword"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.settings.currentPasswordPlaceholder')"
|
2021-01-17 18:57:57 +01:00
|
|
|
type="password"
|
|
|
|
v-focus
|
|
|
|
v-model="totpDisablePassword"/>
|
2020-04-18 01:46:07 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-06-24 01:24:57 +02:00
|
|
|
<x-button @click="totpDisable()" class="is-danger">
|
|
|
|
{{ $t('user.settings.totp.disable') }}
|
|
|
|
</x-button>
|
2020-04-18 01:46:07 +02:00
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
</template>
|
|
|
|
</card>
|
2021-09-04 21:26:38 +02:00
|
|
|
|
|
|
|
<!-- Data export -->
|
|
|
|
<data-export/>
|
2020-10-03 14:58:33 +02:00
|
|
|
|
|
|
|
<!-- Migration -->
|
2021-06-24 01:24:57 +02:00
|
|
|
<card :title="$t('migrate.title')" v-if="migratorsEnabled">
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button
|
|
|
|
:to="{name: 'migrate.start'}"
|
|
|
|
>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('migrate.import') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
|
|
|
</card>
|
2020-10-03 14:58:33 +02:00
|
|
|
|
2021-08-11 21:08:18 +02:00
|
|
|
<!-- Account deletion -->
|
|
|
|
<user-settings-deletion id="deletion"/>
|
|
|
|
|
2020-10-03 14:58:33 +02:00
|
|
|
<!-- Caldav -->
|
2021-06-24 01:24:57 +02:00
|
|
|
<card v-if="caldavEnabled" :title="$t('user.settings.caldav.title')">
|
2021-01-17 18:57:57 +01:00
|
|
|
<p>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.caldav.howTo') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</p>
|
|
|
|
<div class="field has-addons no-input-mobile">
|
|
|
|
<div class="control is-expanded">
|
|
|
|
<input type="text" v-model="caldavUrl" class="input" readonly/>
|
|
|
|
</div>
|
|
|
|
<div class="control">
|
|
|
|
<x-button
|
|
|
|
@click="copy(caldavUrl)"
|
|
|
|
:shadow="false"
|
2021-06-24 01:24:57 +02:00
|
|
|
v-tooltip="$t('misc.copy')"
|
2021-01-17 18:57:57 +01:00
|
|
|
icon="paste"
|
|
|
|
/>
|
2020-10-03 14:58:33 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
<p>
|
2021-07-28 22:58:12 +02:00
|
|
|
<a href="https://vikunja.io/docs/caldav/" rel="noreferrer noopener nofollow" target="_blank">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.caldav.more') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
</card>
|
2020-04-17 22:46:50 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import PasswordUpdateModel from '../../models/passwordUpdate'
|
|
|
|
import PasswordUpdateService from '../../services/passwordUpdateService'
|
|
|
|
import EmailUpdateService from '../../services/emailUpdate'
|
|
|
|
import EmailUpdateModel from '../../models/emailUpdate'
|
|
|
|
import TotpModel from '../../models/totp'
|
|
|
|
import TotpService from '../../services/totp'
|
2020-12-19 01:12:30 +01:00
|
|
|
import UserSettingsService from '../../services/userSettings'
|
|
|
|
import UserSettingsModel from '../../models/userSettings'
|
2021-01-30 21:45:54 +01:00
|
|
|
import {playSoundWhenDoneKey} from '@/helpers/playPop'
|
2021-09-05 13:31:53 +02:00
|
|
|
import {availableLanguages, saveLanguage, getCurrentLanguage} from '../../i18n/setup'
|
2020-04-17 22:46:50 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
import {mapState} from 'vuex'
|
2020-05-29 18:49:50 +02:00
|
|
|
|
2021-07-25 15:27:15 +02:00
|
|
|
import AvatarSettings from '../../components/user/avatar-settings.vue'
|
2020-10-03 14:58:33 +02:00
|
|
|
import copy from 'copy-to-clipboard'
|
2021-07-25 15:27:15 +02:00
|
|
|
import ListSearch from '@/components/tasks/partials/listSearch.vue'
|
2021-08-11 21:08:18 +02:00
|
|
|
import UserSettingsDeletion from '../../components/user/settings/deletion'
|
2021-09-04 21:26:38 +02:00
|
|
|
import DataExport from '../../components/user/settings/data-export'
|
2020-08-02 19:17:29 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'Settings',
|
|
|
|
data() {
|
|
|
|
return {
|
2021-09-08 11:59:38 +02:00
|
|
|
passwordUpdateService: new PasswordUpdateService(),
|
|
|
|
passwordUpdate: new PasswordUpdateModel(),
|
2020-09-05 22:35:52 +02:00
|
|
|
passwordConfirm: '',
|
2020-04-17 22:46:50 +02:00
|
|
|
|
2021-09-08 11:59:38 +02:00
|
|
|
emailUpdateService: new EmailUpdateService(),
|
|
|
|
emailUpdate: new EmailUpdateModel(),
|
2020-04-18 01:46:07 +02:00
|
|
|
|
2021-09-08 11:59:38 +02:00
|
|
|
totpService: new TotpService(),
|
|
|
|
totp: new TotpModel(),
|
2020-09-05 22:35:52 +02:00
|
|
|
totpQR: '',
|
|
|
|
totpEnrolled: false,
|
|
|
|
totpConfirmPasscode: '',
|
|
|
|
totpDisableForm: false,
|
|
|
|
totpDisablePassword: '',
|
2021-01-30 21:45:54 +01:00
|
|
|
playSoundWhenDone: false,
|
2021-06-24 01:24:57 +02:00
|
|
|
language: getCurrentLanguage(),
|
2020-10-03 14:58:33 +02:00
|
|
|
|
2020-12-19 01:12:30 +01:00
|
|
|
settings: UserSettingsModel,
|
2021-09-08 11:59:38 +02:00
|
|
|
userSettingsService: new UserSettingsService(),
|
2021-07-17 23:21:46 +02:00
|
|
|
|
|
|
|
defaultList: null,
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2021-08-11 21:08:18 +02:00
|
|
|
UserSettingsDeletion,
|
2021-07-17 23:21:46 +02:00
|
|
|
ListSearch,
|
2020-09-05 22:35:52 +02:00
|
|
|
AvatarSettings,
|
2021-09-04 21:26:38 +02:00
|
|
|
DataExport,
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
created() {
|
2021-04-07 21:31:14 +02:00
|
|
|
this.settings = this.$store.state.auth.settings
|
2020-11-21 22:25:00 +01:00
|
|
|
|
2021-01-30 21:45:54 +01:00
|
|
|
this.playSoundWhenDone = localStorage.getItem(playSoundWhenDoneKey) === 'true' || localStorage.getItem(playSoundWhenDoneKey) === null
|
|
|
|
|
2021-07-17 23:21:46 +02:00
|
|
|
this.defaultList = this.$store.getters['lists/getListById'](this.settings.defaultListId)
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
this.totpStatus()
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-06-24 01:24:57 +02:00
|
|
|
this.setTitle(this.$t('user.settings.title'))
|
2021-08-11 21:08:18 +02:00
|
|
|
this.anchorHashCheck()
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
2021-01-15 20:56:51 +01:00
|
|
|
computed: {
|
|
|
|
caldavUrl() {
|
|
|
|
let apiBase = window.API_URL.replace('/api/v1', '')
|
|
|
|
if (apiBase === '') { // Frontend and api on the same host which means we need to prefix the frontend url
|
|
|
|
apiBase = this.$store.state.config.frontendUrl
|
|
|
|
}
|
|
|
|
if (apiBase.endsWith('/')) {
|
|
|
|
apiBase = apiBase.substr(0, apiBase.length - 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
return `${apiBase}/dav/principals/${this.userInfo.username}/`
|
|
|
|
},
|
2021-06-24 01:24:57 +02:00
|
|
|
availableLanguages() {
|
2021-09-05 13:31:53 +02:00
|
|
|
return Object.entries(availableLanguages)
|
|
|
|
.map(l => ({code: l[0], title: l[1]}))
|
|
|
|
.sort((a, b) => a.title > b.title)
|
2021-06-24 01:24:57 +02:00
|
|
|
},
|
2021-01-15 20:56:51 +01:00
|
|
|
...mapState({
|
|
|
|
totpEnabled: state => state.config.totpEnabled,
|
|
|
|
migratorsEnabled: state => state.config.availableMigrators !== null && state.config.availableMigrators.length > 0,
|
|
|
|
caldavEnabled: state => state.config.caldavEnabled,
|
|
|
|
userInfo: state => state.auth.info,
|
2021-07-17 23:21:46 +02:00
|
|
|
}),
|
2021-01-15 20:56:51 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
methods: {
|
2021-09-08 11:59:46 +02:00
|
|
|
copy,
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
updatePassword() {
|
|
|
|
if (this.passwordConfirm !== this.passwordUpdate.newPassword) {
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.error({message: this.$t('user.settings.passwordsDontMatch')})
|
2020-09-05 22:35:52 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.passwordUpdateService.update(this.passwordUpdate)
|
|
|
|
.then(() => {
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.success({message: this.$t('user.settings.passwordUpdateSuccess')})
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-08-25 12:28:29 +02:00
|
|
|
.catch(e => this.$message.error(e))
|
2020-04-17 22:46:50 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
updateEmail() {
|
|
|
|
this.emailUpdateService.update(this.emailUpdate)
|
|
|
|
.then(() => {
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.success({message: this.$t('user.settings.updateEmailSuccess')})
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-08-25 12:28:29 +02:00
|
|
|
.catch(e => this.$message.error(e))
|
2020-07-07 22:07:13 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
totpStatus() {
|
|
|
|
if (!this.totpEnabled) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.totpService.get()
|
|
|
|
.then(r => {
|
|
|
|
this.$set(this, 'totp', r)
|
|
|
|
this.totpSetQrCode()
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
// Error code 1016 means totp is not enabled, we don't need an error in that case.
|
|
|
|
if (e.response && e.response.data && e.response.data.code && e.response.data.code === 1016) {
|
2020-04-18 01:46:07 +02:00
|
|
|
this.totpEnrolled = false
|
2020-09-05 22:35:52 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.error(e)
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
|
|
|
},
|
|
|
|
totpSetQrCode() {
|
|
|
|
this.totpService.qrcode()
|
|
|
|
.then(qr => {
|
|
|
|
const urlCreator = window.URL || window.webkitURL
|
|
|
|
this.totpQR = urlCreator.createObjectURL(qr)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
totpEnroll() {
|
|
|
|
this.totpService.enroll()
|
|
|
|
.then(r => {
|
|
|
|
this.totpEnrolled = true
|
|
|
|
this.$set(this, 'totp', r)
|
|
|
|
this.totpSetQrCode()
|
|
|
|
})
|
2021-08-25 12:28:29 +02:00
|
|
|
.catch(e => this.$message.error(e))
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
totpConfirm() {
|
|
|
|
this.totpService.enable({passcode: this.totpConfirmPasscode})
|
|
|
|
.then(() => {
|
|
|
|
this.$set(this.totp, 'enabled', true)
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.success({message: this.$t('user.settings.totp.confirmSuccess')})
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-08-25 12:28:29 +02:00
|
|
|
.catch(e => this.$message.error(e))
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
totpDisable() {
|
|
|
|
this.totpService.disable({password: this.totpDisablePassword})
|
|
|
|
.then(() => {
|
|
|
|
this.totpEnrolled = false
|
|
|
|
this.$set(this, 'totp', new TotpModel())
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.success({message: this.$t('user.settings.totp.disableSuccess')})
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-08-25 12:28:29 +02:00
|
|
|
.catch(e => this.$message.error(e))
|
2020-04-17 22:46:50 +02:00
|
|
|
},
|
2020-12-19 01:12:30 +01:00
|
|
|
updateSettings() {
|
2021-01-30 21:45:54 +01:00
|
|
|
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone)
|
2021-06-24 01:24:57 +02:00
|
|
|
saveLanguage(this.language)
|
2021-07-17 23:21:46 +02:00
|
|
|
this.settings.defaultListId = this.defaultList ? this.defaultList.id : 0
|
2021-01-30 21:45:54 +01:00
|
|
|
|
2020-12-19 01:12:30 +01:00
|
|
|
this.userSettingsService.update(this.settings)
|
2020-11-21 22:25:00 +01:00
|
|
|
.then(() => {
|
2020-12-19 01:12:30 +01:00
|
|
|
this.$store.commit('auth/setUserSettings', this.settings)
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.success({message: this.$t('user.settings.general.savedSuccess')})
|
2020-11-21 22:25:00 +01:00
|
|
|
})
|
2021-08-25 12:28:29 +02:00
|
|
|
.catch(e => this.$message.error(e))
|
2020-11-21 22:25:00 +01:00
|
|
|
},
|
2021-08-11 21:08:18 +02:00
|
|
|
anchorHashCheck() {
|
|
|
|
if (window.location.hash === this.$route.hash) {
|
|
|
|
const el = document.getElementById(this.$route.hash.slice(1))
|
|
|
|
if (el) {
|
|
|
|
window.scrollTo(0, el.offsetTop)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2020-04-17 22:46:50 +02:00
|
|
|
</script>
|