2018-07-04 14:29:17 +02:00
|
|
|
<template>
|
2018-07-10 10:00:07 +02:00
|
|
|
<v-container>
|
2018-07-04 14:29:17 +02:00
|
|
|
<h1 v-if="loading">{{ $t('registration.validation.process') }}</h1>
|
|
|
|
<div v-else>
|
|
|
|
<div v-if="failed">
|
2018-07-10 10:00:07 +02:00
|
|
|
<v-alert :value="true" variant="danger">Error while validating account</v-alert>
|
2018-07-04 14:29:17 +02:00
|
|
|
</div>
|
|
|
|
<h1 v-else>{{ $t('registration.validation.finished') }}</h1>
|
|
|
|
</div>
|
2018-07-10 10:00:07 +02:00
|
|
|
</v-container>
|
2018-07-04 14:29:17 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import fetchStory from '@/api/eventFetch';
|
2018-07-10 10:00:07 +02:00
|
|
|
import { LOGIN_USER } from '@/store/mutation-types';
|
2018-07-04 14:29:17 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Validate',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
|
|
|
failed: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
token: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.validateAction();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
validateAction() {
|
|
|
|
fetchStory(`/users/validate/${this.token}`, this.$store).then((data) => {
|
|
|
|
this.loading = false;
|
|
|
|
localStorage.setItem('token', data.token);
|
|
|
|
localStorage.setItem('refresh_token', data.refresh_token);
|
2018-07-10 10:00:07 +02:00
|
|
|
this.$store.commit(LOGIN_USER, data.account);
|
2018-07-04 14:29:17 +02:00
|
|
|
this.$snotify.success(this.$t('registration.success.login', { username: data.account.username }));
|
|
|
|
this.$router.push({ name: 'Home' });
|
|
|
|
}).catch((err) => {
|
|
|
|
Promise.resolve(err).then(() => {
|
|
|
|
this.failed = true;
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|