2018-11-01 22:34:29 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
2021-12-11 22:08:26 +01:00
|
|
|
<message v-if="errorMsg" class="mb-4">
|
2021-12-12 17:40:13 +01:00
|
|
|
{{ errorMsg }}
|
|
|
|
</message>
|
2021-12-11 22:08:26 +01:00
|
|
|
<div class="has-text-centered mb-4" v-if="successMessage">
|
2021-12-12 17:40:13 +01:00
|
|
|
<message variant="success">
|
|
|
|
{{ successMessage }}
|
|
|
|
</message>
|
|
|
|
<x-button :to="{ name: 'user.login' }">
|
|
|
|
{{ $t('user.auth.login') }}
|
|
|
|
</x-button>
|
|
|
|
</div>
|
|
|
|
<form @submit.prevent="submit" id="form" v-if="!successMessage">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="password1">{{ $t('user.auth.password') }}</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
id="password1"
|
|
|
|
name="password1"
|
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
|
|
|
required
|
|
|
|
type="password"
|
|
|
|
autocomplete="new-password"
|
|
|
|
v-focus
|
|
|
|
v-model="credentials.password"/>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
2021-12-12 17:40:13 +01:00
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="password2">{{ $t('user.auth.passwordRepeat') }}</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
id="password2"
|
|
|
|
name="password2"
|
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
|
|
|
required
|
|
|
|
type="password"
|
|
|
|
autocomplete="new-password"
|
|
|
|
v-model="credentials.password2"
|
|
|
|
@keyup.enter="submit"
|
|
|
|
/>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
2021-12-12 17:40:13 +01:00
|
|
|
</div>
|
2018-11-01 22:34:29 +01:00
|
|
|
|
2021-12-12 17:40:13 +01:00
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
|
|
|
<x-button
|
|
|
|
:loading="this.passwordResetService.loading"
|
|
|
|
@click="submit"
|
|
|
|
>
|
|
|
|
{{ $t('user.auth.resetPassword') }}
|
|
|
|
</x-button>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-12-12 17:40:13 +01:00
|
|
|
</form>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-02-15 13:07:34 +01:00
|
|
|
<script setup lang="ts">
|
2021-11-14 21:57:36 +01:00
|
|
|
import {ref, reactive} from 'vue'
|
2021-11-28 15:18:27 +01:00
|
|
|
import {useI18n} from 'vue-i18n'
|
2018-11-01 22:34:29 +01:00
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
import PasswordResetModel from '@/models/passwordReset'
|
|
|
|
import PasswordResetService from '@/services/passwordReset'
|
2021-11-28 15:18:27 +01:00
|
|
|
import Message from '@/components/misc/message'
|
2021-10-11 19:37:20 +02:00
|
|
|
|
2021-11-28 15:18:27 +01:00
|
|
|
const {t} = useI18n()
|
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 {
|
2021-11-28 15:18:27 +01:00
|
|
|
const {message} = passwordResetService.resetPassword(passwordReset)
|
2021-11-14 21:57:36 +01:00
|
|
|
successMessage.value = message
|
|
|
|
localStorage.removeItem('passwordResetToken')
|
2021-11-28 15:18:27 +01:00
|
|
|
} catch (e) {
|
2021-11-14 21:57:36 +01:00
|
|
|
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>
|