2018-11-01 22:34:29 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
2019-10-19 16:27:56 +02:00
|
|
|
<h2 class="title has-text-centered">Reset your password</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">
|
2019-10-19 16:27:56 +02:00
|
|
|
<label class="label" for="password1">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"
|
|
|
|
placeholder="e.g. ••••••••••••"
|
|
|
|
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">
|
2019-10-19 16:27:56 +02:00
|
|
|
<label class="label" for="password2">Retype your 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="password2"
|
|
|
|
name="password2"
|
|
|
|
placeholder="e.g. ••••••••••••"
|
|
|
|
required
|
|
|
|
type="password"
|
2020-11-02 23:41:18 +01:00
|
|
|
autocomplete="new-password"
|
2020-09-05 22:35:52 +02:00
|
|
|
v-model="credentials.password2"/>
|
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"
|
|
|
|
>
|
|
|
|
Reset your password
|
|
|
|
</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">
|
2018-11-01 22:34:29 +01:00
|
|
|
Loading...
|
|
|
|
</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' }">
|
|
|
|
Login
|
|
|
|
</x-button>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
2020-07-18 21:39:30 +02:00
|
|
|
<legal/>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import PasswordResetModel from '../../models/passwordReset'
|
|
|
|
import PasswordResetService from '../../services/passwordReset'
|
|
|
|
import Legal from '../../components/misc/legal'
|
2018-11-01 22:34:29 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Legal,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
passwordResetService: PasswordResetService,
|
|
|
|
credentials: {
|
|
|
|
password: '',
|
|
|
|
password2: '',
|
|
|
|
},
|
|
|
|
errorMsg: '',
|
|
|
|
successMessage: '',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.passwordResetService = new PasswordResetService()
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.setTitle('Reset your password')
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submit() {
|
|
|
|
this.errorMsg = ''
|
2018-11-01 22:34:29 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
if (this.credentials.password2 !== this.credentials.password) {
|
|
|
|
this.errorMsg = 'Passwords don\'t match'
|
|
|
|
return
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
|
|
|
|
let passwordReset = new PasswordResetModel({newPassword: this.credentials.password})
|
|
|
|
this.passwordResetService.resetPassword(passwordReset)
|
|
|
|
.then(response => {
|
2020-12-30 21:43:43 +01:00
|
|
|
this.successMessage = response.message
|
2020-09-05 22:35:52 +02:00
|
|
|
localStorage.removeItem('passwordResetToken')
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.errorMsg = e.response.data.message
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
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>
|