2021-10-26 20:58:02 +00:00
|
|
|
<template>
|
2021-10-31 13:38:13 +00:00
|
|
|
<card v-if="isLocalUser" :title="$t('user.settings.newPasswordTitle')" :loading="passwordUpdateService.loading">
|
2021-10-26 20:58:02 +00:00
|
|
|
<form @submit.prevent="updatePassword">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="newPassword">{{ $t('user.settings.newPassword') }}</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
autocomplete="new-password"
|
|
|
|
@keyup.enter="updatePassword"
|
|
|
|
class="input"
|
|
|
|
id="newPassword"
|
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
|
|
|
type="password"
|
|
|
|
v-model="passwordUpdate.newPassword"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="newPasswordConfirm">{{ $t('user.settings.newPasswordConfirm') }}</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
autocomplete="new-password"
|
|
|
|
@keyup.enter="updatePassword"
|
|
|
|
class="input"
|
|
|
|
id="newPasswordConfirm"
|
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
|
|
|
type="password"
|
|
|
|
v-model="passwordConfirm"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="currentPassword">{{ $t('user.settings.currentPassword') }}</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
autocomplete="current-password"
|
|
|
|
@keyup.enter="updatePassword"
|
|
|
|
class="input"
|
|
|
|
id="currentPassword"
|
|
|
|
:placeholder="$t('user.settings.currentPasswordPlaceholder')"
|
|
|
|
type="password"
|
|
|
|
v-model="passwordUpdate.oldPassword"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<x-button
|
|
|
|
:loading="passwordUpdateService.loading"
|
|
|
|
@click="updatePassword"
|
|
|
|
class="is-fullwidth mt-4">
|
|
|
|
{{ $t('misc.save') }}
|
|
|
|
</x-button>
|
|
|
|
</card>
|
|
|
|
</template>
|
|
|
|
|
2022-02-15 12:07:34 +00:00
|
|
|
<script lang="ts">
|
2022-07-04 22:11:12 +00:00
|
|
|
export default {name: 'user-settings-password-update'}
|
2021-10-26 20:58:02 +00:00
|
|
|
</script>
|
2022-05-14 14:50:52 +00:00
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import {ref, reactive, shallowReactive, computed} from 'vue'
|
2022-09-21 01:37:39 +00:00
|
|
|
import {useI18n} from 'vue-i18n'
|
2022-05-14 14:50:52 +00:00
|
|
|
|
|
|
|
import PasswordUpdateService from '@/services/passwordUpdateService'
|
|
|
|
import PasswordUpdateModel from '@/models/passwordUpdate'
|
|
|
|
|
|
|
|
import {useTitle} from '@/composables/useTitle'
|
|
|
|
import {success, error} from '@/message'
|
2022-09-21 01:37:39 +00:00
|
|
|
import {useAuthStore} from '@/stores/auth'
|
2022-05-14 14:50:52 +00:00
|
|
|
|
|
|
|
const passwordUpdateService = shallowReactive(new PasswordUpdateService())
|
|
|
|
const passwordUpdate = reactive(new PasswordUpdateModel())
|
|
|
|
const passwordConfirm = ref('')
|
|
|
|
|
2022-05-23 05:23:59 +00:00
|
|
|
const {t} = useI18n({useScope: 'global'})
|
2022-05-14 14:50:52 +00:00
|
|
|
useTitle(() => `${t('user.settings.newPasswordTitle')} - ${t('user.settings.title')}`)
|
|
|
|
|
2022-09-21 01:37:39 +00:00
|
|
|
const authStore = useAuthStore()
|
|
|
|
const isLocalUser = computed(() => authStore.info?.isLocalUser)
|
2022-05-14 14:50:52 +00:00
|
|
|
|
|
|
|
async function updatePassword() {
|
|
|
|
if (passwordConfirm.value !== passwordUpdate.newPassword) {
|
|
|
|
error({message: t('user.settings.passwordsDontMatch')})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
await passwordUpdateService.update(passwordUpdate)
|
|
|
|
success({message: t('user.settings.passwordUpdateSuccess')})
|
|
|
|
}
|
|
|
|
</script>
|