2020-02-13 15:48:12 +01:00
|
|
|
<template>
|
|
|
|
<section class="section container">
|
2020-02-18 08:57:00 +01:00
|
|
|
<h1 class="title" v-if="loading">{{ $t("Your email is being changed") }}</h1>
|
2020-02-13 15:48:12 +01:00
|
|
|
<div v-else>
|
|
|
|
<div v-if="failed">
|
|
|
|
<b-message :title="$t('Error while changing email')" type="is-danger">
|
2020-02-18 08:57:00 +01:00
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"Either the email has already been changed, either the validation token is incorrect."
|
|
|
|
)
|
|
|
|
}}
|
2020-02-13 15:48:12 +01:00
|
|
|
</b-message>
|
|
|
|
</div>
|
2020-02-18 08:57:00 +01:00
|
|
|
<h1 class="title" v-else>{{ $t("Your email has been changed") }}</h1>
|
2020-02-13 15:48:12 +01:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
|
|
import { VALIDATE_EMAIL } from "../../graphql/user";
|
|
|
|
import RouteName from "../../router/name";
|
|
|
|
import { ICurrentUser } from "../../types/current-user.model";
|
2020-02-13 15:48:12 +01:00
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class Validate extends Vue {
|
|
|
|
@Prop({ type: String, required: true }) token!: string;
|
|
|
|
|
|
|
|
loading = true;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-02-13 15:48:12 +01:00
|
|
|
failed = false;
|
|
|
|
|
|
|
|
async created() {
|
|
|
|
await this.validateAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
async validateAction() {
|
|
|
|
try {
|
2020-02-18 08:57:00 +01:00
|
|
|
await this.$apollo.mutate<{ validateEmail: ICurrentUser }>({
|
2020-02-13 15:48:12 +01:00
|
|
|
mutation: VALIDATE_EMAIL,
|
|
|
|
variables: {
|
|
|
|
token: this.token,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
this.loading = false;
|
|
|
|
return await this.$router.push({ name: RouteName.HOME });
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
this.failed = true;
|
2020-02-18 08:57:00 +01:00
|
|
|
return undefined;
|
2020-02-13 15:48:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|