2020-02-13 15:48:12 +01:00
|
|
|
<template>
|
|
|
|
<section class="section container">
|
2020-11-30 10:24:11 +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;
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
async created(): Promise<void> {
|
2020-02-13 15:48:12 +01:00
|
|
|
await this.validateAction();
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
async validateAction(): Promise<void> {
|
2020-02-13 15:48:12 +01:00
|
|
|
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;
|
2020-11-19 17:06:28 +01:00
|
|
|
await this.$router.push({ name: RouteName.HOME });
|
2020-02-13 15:48:12 +01:00
|
|
|
} catch (err) {
|
2021-03-23 16:38:37 +01:00
|
|
|
this.loading = false;
|
2020-02-13 15:48:12 +01:00
|
|
|
console.error(err);
|
|
|
|
this.failed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|