2018-11-01 22:34:29 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
2021-06-24 01:24:57 +02:00
|
|
|
<h2 class="title has-text-centered">{{ $t('user.auth.resetPassword') }}</h2>
|
2018-11-01 22:34:29 +01:00
|
|
|
<div class="box">
|
2020-09-05 22:35:52 +02:00
|
|
|
<form @submit.prevent="submit" id="form" v-if="!successMessage">
|
2018-11-01 22:34:29 +01:00
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="password1">{{ $t('user.auth.password') }}</label>
|
2018-11-01 22:34:29 +01:00
|
|
|
<div class="control">
|
2020-09-05 22:35:52 +02:00
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
id="password1"
|
|
|
|
name="password1"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
2020-09-05 22:35:52 +02:00
|
|
|
required
|
|
|
|
type="password"
|
2020-11-02 23:41:18 +01:00
|
|
|
autocomplete="new-password"
|
2020-09-05 22:35:52 +02:00
|
|
|
v-focus
|
|
|
|
v-model="credentials.password"/>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="password2">{{ $t('user.auth.passwordRepeat') }}</label>
|
2018-11-01 22:34:29 +01:00
|
|
|
<div class="control">
|
2020-09-05 22:35:52 +02:00
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
id="password2"
|
|
|
|
name="password2"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
2020-09-05 22:35:52 +02:00
|
|
|
required
|
|
|
|
type="password"
|
2020-11-02 23:41:18 +01:00
|
|
|
autocomplete="new-password"
|
2021-07-30 14:46:00 +02:00
|
|
|
v-model="credentials.password2"
|
|
|
|
@keyup.enter="submit"
|
|
|
|
/>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button
|
|
|
|
:loading="this.passwordResetService.loading"
|
|
|
|
@click="submit"
|
|
|
|
>
|
2021-07-30 12:23:31 +02:00
|
|
|
{{ $t('user.auth.resetPassword') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-03-02 11:25:10 +01:00
|
|
|
<div class="notification is-info" v-if="this.passwordResetService.loading">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.loading') }}
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
2020-03-23 18:32:06 +01:00
|
|
|
<div class="notification is-danger" v-if="errorMsg">
|
2020-01-31 16:33:14 +01:00
|
|
|
{{ errorMsg }}
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
2020-09-05 22:35:52 +02:00
|
|
|
<div class="has-text-centered" v-if="successMessage">
|
2018-11-01 22:34:29 +01:00
|
|
|
<div class="notification is-success">
|
|
|
|
{{ successMessage }}
|
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button :to="{ name: 'user.login' }">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.auth.login') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
2021-11-14 21:57:36 +01:00
|
|
|
<Legal />
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
<script setup>
|
|
|
|
import {ref, reactive} from 'vue'
|
|
|
|
import { useI18n } from 'vue-i18n'
|
2018-11-01 22:34:29 +01:00
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
import Legal from '@/components/misc/legal'
|
2021-10-11 19:37:20 +02:00
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
import PasswordResetModel from '@/models/passwordReset'
|
|
|
|
import PasswordResetService from '@/services/passwordReset'
|
|
|
|
import { useTitle } from '@/composables/useTitle'
|
2021-10-11 19:37:20 +02:00
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
const { t } = useI18n()
|
|
|
|
useTitle(() => t('user.auth.resetPassword'))
|
2018-11-01 22:34:29 +01:00
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
const credentials = reactive({
|
|
|
|
password: '',
|
|
|
|
password2: '',
|
|
|
|
})
|
2020-09-05 22:35:52 +02:00
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
const passwordResetService = reactive(new PasswordResetService())
|
|
|
|
const errorMsg = ref('')
|
|
|
|
const successMessage = ref('')
|
|
|
|
|
|
|
|
async function submit() {
|
|
|
|
errorMsg.value = ''
|
|
|
|
|
|
|
|
if (credentials.password2 !== credentials.password) {
|
|
|
|
errorMsg.value = t('user.auth.passwordsDontMatch')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const passwordReset = new PasswordResetModel({newPassword: credentials.password})
|
|
|
|
try {
|
|
|
|
const { message } = passwordResetService.resetPassword(passwordReset)
|
|
|
|
successMessage.value = message
|
|
|
|
localStorage.removeItem('passwordResetToken')
|
|
|
|
} catch(e) {
|
|
|
|
errorMsg.value = e.response.data.message
|
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2018-11-01 22:34:29 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2020-09-05 22:35:52 +02:00
|
|
|
.button {
|
2021-01-23 18:18:09 +01:00
|
|
|
margin: 0 0.4rem 0 0;
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2018-11-01 22:34:29 +01:00
|
|
|
</style>
|