2018-07-04 14:29:17 +02:00
|
|
|
<template>
|
2018-07-10 10:00:07 +02:00
|
|
|
<v-container>
|
2018-11-06 10:30:27 +01:00
|
|
|
<h1 v-if="loading"><translate>Your account is being validated</translate></h1>
|
2018-07-04 14:29:17 +02:00
|
|
|
<div v-else>
|
|
|
|
<div v-if="failed">
|
2018-11-06 10:30:27 +01:00
|
|
|
<v-alert :value="true" variant="danger"><translate>Error while validating account</translate></v-alert>
|
2018-07-04 14:29:17 +02:00
|
|
|
</div>
|
2018-11-06 10:30:27 +01:00
|
|
|
<h1 v-else><translate>Your account has been validated</translate></h1>
|
2018-07-04 14:29:17 +02:00
|
|
|
</div>
|
2018-07-10 10:00:07 +02:00
|
|
|
</v-container>
|
2018-07-04 14:29:17 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-11-06 10:30:27 +01:00
|
|
|
import { VALIDATE_USER } from '@/graphql/user';
|
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() {
|
2018-11-06 10:30:27 +01:00
|
|
|
this.$apollo.mutate({
|
|
|
|
mutation: VALIDATE_USER,
|
|
|
|
variables: {
|
|
|
|
token: this.token,
|
|
|
|
},
|
|
|
|
}).then((data) => {
|
2018-07-04 14:29:17 +02:00
|
|
|
this.loading = false;
|
2018-11-06 10:30:27 +01:00
|
|
|
console.log(data);
|
|
|
|
this.saveUserData(data.data);
|
|
|
|
this.$router.push({name: 'Home'});
|
|
|
|
}).catch((error) => {
|
|
|
|
this.loading = false;
|
|
|
|
console.log(error);
|
|
|
|
this.failed = true;
|
2018-07-04 14:29:17 +02:00
|
|
|
});
|
|
|
|
},
|
2018-11-06 10:30:27 +01:00
|
|
|
saveUserData({validateUser: login}) {
|
|
|
|
localStorage.setItem(AUTH_USER_ID, login.user.id);
|
|
|
|
localStorage.setItem(AUTH_USER_ACTOR, JSON.stringify(login.actor));
|
|
|
|
localStorage.setItem(AUTH_TOKEN, login.token);
|
|
|
|
}
|
2018-07-04 14:29:17 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|