Add user email verification when registering (#3)
This commit is contained in:
parent
4a78a508df
commit
89023908b5
3 changed files with 29 additions and 2 deletions
|
@ -105,6 +105,12 @@
|
||||||
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
|
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
|
||||||
router.push({name: 'passwordReset'})
|
router.push({name: 'passwordReset'})
|
||||||
}
|
}
|
||||||
|
// Email verification
|
||||||
|
if(this.$route.query.userEmailConfirm !== undefined) {
|
||||||
|
localStorage.removeItem('emailConfirmToken') // Delete an eventually preexisting old token
|
||||||
|
localStorage.setItem('emailConfirmToken', this.$route.query.userEmailConfirm)
|
||||||
|
router.push({name: 'login'})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.user.authenticated) {
|
if (this.user.authenticated) {
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<div>
|
<div>
|
||||||
<h2 class="title">Login</h2>
|
<h2 class="title">Login</h2>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
<div v-if="confirmedEmailSuccess" class="notification is-success has-text-centered">
|
||||||
|
You successfully confirmed your email! You can log in now.
|
||||||
|
</div>
|
||||||
<form id="loginform" @submit.prevent="submit">
|
<form id="loginform" @submit.prevent="submit">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
|
@ -32,6 +35,7 @@
|
||||||
<script>
|
<script>
|
||||||
import auth from '../../auth'
|
import auth from '../../auth'
|
||||||
import router from '../../router'
|
import router from '../../router'
|
||||||
|
import {HTTP} from '../../http-common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -41,10 +45,27 @@
|
||||||
password: ''
|
password: ''
|
||||||
},
|
},
|
||||||
error: '',
|
error: '',
|
||||||
|
confirmedEmailSuccess: false,
|
||||||
loading: false
|
loading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
|
// Try to verify the email
|
||||||
|
let emailVerifyToken = localStorage.getItem('emailConfirmToken')
|
||||||
|
if (emailVerifyToken !== '') {
|
||||||
|
this.loading = true
|
||||||
|
HTTP.post(`user/confirm`, {token: emailVerifyToken})
|
||||||
|
.then(() => {
|
||||||
|
localStorage.removeItem('emailConfirmToken')
|
||||||
|
this.loading = false
|
||||||
|
this.confirmedEmailSuccess = true
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
this.loading = false
|
||||||
|
this.error = e.response.data.message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the user is already logged in, if so, redirect him to the homepage
|
// Check if the user is already logged in, if so, redirect him to the homepage
|
||||||
if (auth.user.authenticated) {
|
if (auth.user.authenticated) {
|
||||||
router.push({name: 'home'})
|
router.push({name: 'home'})
|
||||||
|
|
4
todo.md
4
todo.md
|
@ -59,6 +59,6 @@
|
||||||
* [ ] Google fonts raus (sollen von lokal geladen werden)
|
* [ ] Google fonts raus (sollen von lokal geladen werden)
|
||||||
* [ ] Ladeanimationen erst nach 100ms anzeigen, sonst wird das überflüssigerweise angezeigt
|
* [ ] Ladeanimationen erst nach 100ms anzeigen, sonst wird das überflüssigerweise angezeigt
|
||||||
|
|
||||||
* [ ] Userstuff
|
* [x] Userstuff
|
||||||
* [ ] Email-Verification
|
* [x] Email-Verification
|
||||||
* [x] Password forgot
|
* [x] Password forgot
|
Loading…
Reference in a new issue