feat: allow openid users to export their data without a password (#918)

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/918
Reviewed-by: dpschen <dpschen@noreply.kolaente.de>
Co-authored-by: konrad <k@knt.li>
Co-committed-by: konrad <k@knt.li>
This commit is contained in:
konrad 2021-10-31 13:16:28 +00:00
parent a515b0c3a4
commit 5b406b0172
2 changed files with 58 additions and 44 deletions

View file

@ -1,27 +1,29 @@
<template> <template>
<div class="content"> <div class="content">
<h1>{{ $t('user.export.downloadTitle') }}</h1> <h1>{{ $t('user.export.downloadTitle') }}</h1>
<p>{{ $t('user.export.descriptionPasswordRequired') }}</p> <template v-if="isLocalUser">
<div class="field"> <p>{{ $t('user.export.descriptionPasswordRequired') }}</p>
<label class="label" for="currentPasswordDataExport"> <div class="field">
{{ $t('user.settings.currentPassword') }} <label class="label" for="currentPasswordDataExport">
</label> {{ $t('user.settings.currentPassword') }}
<div class="control"> </label>
<input <div class="control">
class="input" <input
:class="{'is-danger': errPasswordRequired}" class="input"
id="currentPasswordDataExport" :class="{'is-danger': errPasswordRequired}"
:placeholder="$t('user.settings.currentPasswordPlaceholder')" id="currentPasswordDataExport"
type="password" :placeholder="$t('user.settings.currentPasswordPlaceholder')"
v-model="password" type="password"
@keyup="() => errPasswordRequired = password === ''" v-model="password"
ref="passwordInput" @keyup="() => errPasswordRequired = password === ''"
/> ref="passwordInput"
/>
</div>
<p class="help is-danger" v-if="errPasswordRequired">
{{ $t('user.deletion.passwordRequired') }}
</p>
</div> </div>
<p class="help is-danger" v-if="errPasswordRequired"> </template>
{{ $t('user.deletion.passwordRequired') }}
</p>
</div>
<x-button <x-button
v-focus v-focus
@ -48,9 +50,14 @@ export default {
created() { created() {
this.dataExportService = new DataExportService() this.dataExportService = new DataExportService()
}, },
computed: {
isLocalUser() {
return this.$store.state.auth.info?.isLocalUser
},
},
methods: { methods: {
download() { download() {
if (this.password === '') { if (this.password === '' && this.isLocalUser) {
this.errPasswordRequired = true this.errPasswordRequired = true
this.$refs.passwordInput.focus() this.$refs.passwordInput.focus()
return return

View file

@ -3,29 +3,31 @@
<p> <p>
{{ $t('user.export.description') }} {{ $t('user.export.description') }}
</p> </p>
<p> <template v-if="isLocalUser">
{{ $t('user.export.descriptionPasswordRequired') }} <p>
</p> {{ $t('user.export.descriptionPasswordRequired') }}
<div class="field">
<label class="label" for="currentPasswordDataExport">
{{ $t('user.settings.currentPassword') }}
</label>
<div class="control">
<input
class="input"
:class="{'is-danger': errPasswordRequired}"
id="currentPasswordDataExport"
:placeholder="$t('user.settings.currentPasswordPlaceholder')"
type="password"
v-model="password"
@keyup="() => errPasswordRequired = password === ''"
ref="passwordInput"
/>
</div>
<p class="help is-danger" v-if="errPasswordRequired">
{{ $t('user.deletion.passwordRequired') }}
</p> </p>
</div> <div class="field">
<label class="label" for="currentPasswordDataExport">
{{ $t('user.settings.currentPassword') }}
</label>
<div class="control">
<input
class="input"
:class="{'is-danger': errPasswordRequired}"
id="currentPasswordDataExport"
:placeholder="$t('user.settings.currentPasswordPlaceholder')"
type="password"
v-model="password"
@keyup="() => errPasswordRequired = password === ''"
ref="passwordInput"
/>
</div>
<p class="help is-danger" v-if="errPasswordRequired">
{{ $t('user.deletion.passwordRequired') }}
</p>
</div>
</template>
<x-button <x-button
:loading="dataExportService.loading" :loading="dataExportService.loading"
@ -48,12 +50,17 @@ export default {
errPasswordRequired: false, errPasswordRequired: false,
} }
}, },
computed: {
isLocalUser() {
return this.$store.state.auth.info?.isLocalUser
},
},
mounted() { mounted() {
this.setTitle(`${this.$t('user.export.title')} - ${this.$t('user.settings.title')}`) this.setTitle(`${this.$t('user.export.title')} - ${this.$t('user.settings.title')}`)
}, },
methods: { methods: {
async requestDataExport() { async requestDataExport() {
if (this.password === '') { if (this.password === '' && this.isLocalUser) {
this.errPasswordRequired = true this.errPasswordRequired = true
this.$refs.passwordInput.focus() this.$refs.passwordInput.focus()
return return