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"
|
|
|
|
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"
|
|
|
|
v-model="credentials.password2"/>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
2020-09-05 22:35:52 +02:00
|
|
|
<button :class="{ 'is-loading': this.passwordResetService.loading}" class="button is-primary"
|
|
|
|
type="submit">Reset your password
|
|
|
|
</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>
|
2020-06-17 22:24:37 +02:00
|
|
|
<router-link :to="{ name: 'user.login' }" class="button is-primary">Login</router-link>
|
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 => {
|
|
|
|
this.successMessage = response.data.message
|
|
|
|
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 {
|
|
|
|
margin: 0 0.4em 0 0;
|
|
|
|
}
|
2018-11-01 22:34:29 +01:00
|
|
|
</style>
|