2018-11-01 22:34:29 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<h2 class="title">Reset your password</h2>
|
|
|
|
<div class="box">
|
|
|
|
<form id="loginform" @submit.prevent="submit" v-if="!isSuccess">
|
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
2018-12-25 16:03:51 +01:00
|
|
|
<input v-focus type="text" class="input" name="email" placeholder="Email-Adress" v-model="email" required>
|
2018-11-01 22:34:29 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
|
|
|
<button type="submit" class="button is-primary" v-bind:class="{ 'is-loading': loading}">Send me a password reset link</button>
|
|
|
|
<router-link :to="{ name: 'login' }" class="button">Login</router-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="notification is-danger" v-if="error">
|
|
|
|
{{ error }}
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<div v-if="isSuccess" class="has-text-centered">
|
|
|
|
<div class="notification is-success">
|
|
|
|
Check your inbox! You should have a mail with instructions on how to reset your password.
|
|
|
|
</div>
|
|
|
|
<router-link :to="{ name: 'login' }" class="button is-primary">Login</router-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {HTTP} from '../../http-common'
|
2018-11-27 11:23:50 +01:00
|
|
|
import message from '../../message'
|
2018-11-01 22:34:29 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2018-12-20 13:13:55 +01:00
|
|
|
email: '',
|
2018-11-01 22:34:29 +01:00
|
|
|
error: '',
|
|
|
|
isSuccess: false,
|
|
|
|
loading: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submit() {
|
2018-11-27 11:23:50 +01:00
|
|
|
const cancel = message.setLoading(this)
|
2018-11-01 22:34:29 +01:00
|
|
|
this.error = ''
|
|
|
|
let credentials = {
|
2018-12-20 13:13:55 +01:00
|
|
|
email: this.email,
|
2018-11-01 22:34:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HTTP.post(`user/password/token`, credentials)
|
|
|
|
.then(() => {
|
2018-11-27 11:23:50 +01:00
|
|
|
cancel()
|
2018-11-01 22:34:29 +01:00
|
|
|
this.isSuccess = true
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2018-11-27 11:23:50 +01:00
|
|
|
cancel()
|
2018-11-01 22:34:29 +01:00
|
|
|
this.handleError(e)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleError(e) {
|
|
|
|
this.error = e.response.data.message
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.button {
|
|
|
|
margin: 0 0.4em 0 0;
|
|
|
|
}
|
|
|
|
</style>
|