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">
|
|
|
|
<form id="form" @submit.prevent="submit" v-if="!successMessage">
|
|
|
|
<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">
|
2019-10-19 16:27:56 +02:00
|
|
|
<input v-focus type="password" class="input" id="password1" name="password1" placeholder="e.g. ••••••••••••" v-model="credentials.password" required/>
|
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">
|
2019-10-19 16:27:56 +02:00
|
|
|
<input type="password" class="input" id="password2" name="password2" placeholder="e.g. ••••••••••••" v-model="credentials.password2" required/>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
2019-03-02 11:25:10 +01:00
|
|
|
<button type="submit" class="button is-primary" :class="{ 'is-loading': this.passwordResetService.loading}">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>
|
|
|
|
<div class="notification is-danger" v-if="error">
|
|
|
|
{{ error }}
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<div v-if="successMessage" class="has-text-centered">
|
|
|
|
<div class="notification is-success">
|
|
|
|
{{ successMessage }}
|
|
|
|
</div>
|
|
|
|
<router-link :to="{ name: 'login' }" class="button is-primary">Login</router-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-03-02 11:25:10 +01:00
|
|
|
import PasswordResetModel from '../../models/passwordReset'
|
|
|
|
import PasswordResetService from '../../services/passwordReset'
|
2018-11-01 22:34:29 +01:00
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
passwordResetService: PasswordResetService,
|
|
|
|
credentials: {
|
|
|
|
password: '',
|
|
|
|
password2: '',
|
|
|
|
},
|
|
|
|
error: '',
|
|
|
|
successMessage: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.passwordResetService = new PasswordResetService()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submit() {
|
|
|
|
this.error = ''
|
2018-11-01 22:34:29 +01:00
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
if (this.credentials.password2 !== this.credentials.password) {
|
|
|
|
this.error = 'Passwords don\'t match'
|
|
|
|
return
|
2018-11-01 22:34:29 +01:00
|
|
|
}
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
let passwordReset = new PasswordResetModel({new_password: this.credentials.password})
|
|
|
|
this.passwordResetService.resetPassword(passwordReset)
|
|
|
|
.then(response => {
|
|
|
|
this.successMessage = response.data.message
|
|
|
|
localStorage.removeItem('passwordResetToken')
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.error = e.response.data.message
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-01 22:34:29 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.button {
|
|
|
|
margin: 0 0.4em 0 0;
|
|
|
|
}
|
|
|
|
</style>
|