2018-11-01 21:34:29 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2021-12-11 21:08:26 +00:00
|
|
|
<message v-if="errorMsg" class="mb-4">
|
2021-12-12 16:40:13 +00:00
|
|
|
{{ errorMsg }}
|
|
|
|
</message>
|
2021-12-11 21:08:26 +00:00
|
|
|
<div class="has-text-centered mb-4" v-if="successMessage">
|
2021-12-12 16:40:13 +00:00
|
|
|
<message variant="success">
|
|
|
|
{{ successMessage }}
|
|
|
|
</message>
|
2022-10-20 14:15:58 +00:00
|
|
|
<x-button :to="{ name: 'user.login' }" class="mt-4">
|
2021-12-12 16:40:13 +00:00
|
|
|
{{ $t('user.auth.login') }}
|
|
|
|
</x-button>
|
|
|
|
</div>
|
2023-04-12 14:15:40 +00:00
|
|
|
<form @submit.prevent="resetPassword" id="form" v-if="!successMessage">
|
2021-12-12 16:40:13 +00:00
|
|
|
<div class="field">
|
2022-10-20 14:07:36 +00:00
|
|
|
<label class="label" for="password">{{ $t('user.auth.password') }}</label>
|
2023-04-12 14:15:40 +00:00
|
|
|
<Password @submit="resetPassword" @update:modelValue="v => credentials.password = v"/>
|
2021-12-12 16:40:13 +00:00
|
|
|
</div>
|
2018-11-01 21:34:29 +00:00
|
|
|
|
2021-12-12 16:40:13 +00:00
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
|
|
|
<x-button
|
2022-10-03 13:10:09 +00:00
|
|
|
:loading="passwordResetService.loading"
|
2023-04-12 14:15:40 +00:00
|
|
|
@click="resetPassword"
|
2021-12-12 16:40:13 +00:00
|
|
|
>
|
|
|
|
{{ $t('user.auth.resetPassword') }}
|
|
|
|
</x-button>
|
2018-11-01 21:34:29 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-12-12 16:40:13 +00:00
|
|
|
</form>
|
2018-11-01 21:34:29 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-02-15 12:07:34 +00:00
|
|
|
<script setup lang="ts">
|
2021-11-14 20:57:36 +00:00
|
|
|
import {ref, reactive} from 'vue'
|
2018-11-01 21:34:29 +00:00
|
|
|
|
2021-11-14 20:57:36 +00:00
|
|
|
import PasswordResetModel from '@/models/passwordReset'
|
|
|
|
import PasswordResetService from '@/services/passwordReset'
|
2022-05-14 15:05:49 +00:00
|
|
|
import Message from '@/components/misc/message.vue'
|
2022-10-20 14:07:36 +00:00
|
|
|
import Password from '@/components/input/password.vue'
|
2021-10-11 17:37:20 +00:00
|
|
|
|
2021-11-14 20:57:36 +00:00
|
|
|
const credentials = reactive({
|
|
|
|
password: '',
|
|
|
|
})
|
2020-09-05 20:35:52 +00:00
|
|
|
|
2021-11-14 20:57:36 +00:00
|
|
|
const passwordResetService = reactive(new PasswordResetService())
|
|
|
|
const errorMsg = ref('')
|
|
|
|
const successMessage = ref('')
|
|
|
|
|
2023-04-12 14:15:40 +00:00
|
|
|
async function resetPassword() {
|
2021-11-14 20:57:36 +00:00
|
|
|
errorMsg.value = ''
|
2022-10-20 14:07:36 +00:00
|
|
|
|
|
|
|
if(credentials.password === '') {
|
2021-11-14 20:57:36 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const passwordReset = new PasswordResetModel({newPassword: credentials.password})
|
|
|
|
try {
|
2022-10-20 14:15:58 +00:00
|
|
|
const {message} = await passwordResetService.resetPassword(passwordReset)
|
2021-11-14 20:57:36 +00:00
|
|
|
successMessage.value = message
|
|
|
|
localStorage.removeItem('passwordResetToken')
|
2021-11-28 14:18:27 +00:00
|
|
|
} catch (e) {
|
2021-11-14 20:57:36 +00:00
|
|
|
errorMsg.value = e.response.data.message
|
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
2018-11-01 21:34:29 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2020-09-05 20:35:52 +00:00
|
|
|
.button {
|
2021-01-23 17:18:09 +00:00
|
|
|
margin: 0 0.4rem 0 0;
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
2018-11-01 21:34:29 +00:00
|
|
|
</style>
|