Introduce group basic federation, event new page and notifications

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-02-18 08:57:00 +01:00
parent 300ef8f245
commit 4144e9ffd0
416 changed files with 32220 additions and 16750 deletions

View File

@@ -1,31 +1,33 @@
<template>
<section class="section container">
<h1 class="title" v-if="loading">
{{ $t('Your email is being changed') }}
</h1>
<h1 class="title" v-if="loading">{{ $t("Your email is being changed") }}</h1>
<div v-else>
<div v-if="failed">
<b-message :title="$t('Error while changing email')" type="is-danger">
{{ $t('Either the email has already been changed, either the validation token is incorrect.') }}
{{
$t(
"Either the email has already been changed, either the validation token is incorrect."
)
}}
</b-message>
</div>
<h1 class="title" v-else>
{{ $t('Your email has been changed') }}
</h1>
<h1 class="title" v-else>{{ $t("Your email has been changed") }}</h1>
</div>
</section>
</template>
<script lang="ts">
import { VALIDATE_EMAIL } from '@/graphql/user';
import { Component, Prop, Vue } from 'vue-property-decorator';
import { RouteName } from '@/router';
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";
@Component
export default class Validate extends Vue {
@Prop({ type: String, required: true }) token!: string;
loading = true;
failed = false;
async created() {
@@ -34,7 +36,7 @@ export default class Validate extends Vue {
async validateAction() {
try {
await this.$apollo.mutate<{ validateEmail }>({
await this.$apollo.mutate<{ validateEmail: ICurrentUser }>({
mutation: VALIDATE_EMAIL,
variables: {
token: this.token,
@@ -42,10 +44,10 @@ export default class Validate extends Vue {
});
this.loading = false;
return await this.$router.push({ name: RouteName.HOME });
} catch (err) {
console.error(err);
this.failed = true;
return undefined;
}
}
}

View File

@@ -2,36 +2,55 @@
<section class="section container" v-if="!currentUser.isLoggedIn">
<div class="columns is-mobile is-centered">
<div class="column is-half-desktop">
<h1 class="title">
{{ $t('Welcome back!') }}
</h1>
<b-message v-if="errorCode === LoginErrorCode.NEED_TO_LOGIN" title="Info" type="is-info">
{{ $t('You need to login.') }}
</b-message>
<h1 class="title">{{ $t("Welcome back!") }}</h1>
<b-message
v-if="errorCode === LoginErrorCode.NEED_TO_LOGIN"
title="Info"
type="is-info"
:aria-close-label="$t('Close')"
>{{ $t("You need to login.") }}</b-message
>
<b-message title="Error" type="is-danger" v-for="error in errors" :key="error">
<span v-if="error === LoginError.USER_NOT_CONFIRMED">
<span>{{ $t("The user account you're trying to login as has not been confirmed yet. Check your email inbox and eventually your spam folder.") }}</span>
<span>
{{
$t(
"The user account you're trying to login as has not been confirmed yet. Check your email inbox and eventually your spam folder."
)
}}
</span>
<i18n path="You may also ask to {resend_confirmation_email}.">
<router-link slot="resend_confirmation_email" :to="{ name: RouteName.RESEND_CONFIRMATION }">{{ $t('resend confirmation email') }}</router-link>
<router-link
slot="resend_confirmation_email"
:to="{ name: RouteName.RESEND_CONFIRMATION }"
>{{ $t("resend confirmation email") }}</router-link
>
</i18n>
</span>
<span v-if="error === LoginError.USER_EMAIL_PASSWORD_INVALID">
{{ $t('Impossible to login, your email or password seems incorrect.') }}
</span>
<!-- TODO: Shouldn't we hide this information ? -->
<span v-if="error === LoginError.USER_DOES_NOT_EXIST">
{{ $t('No user account with this email was found. Maybe you made a typo?') }}
</span>
<span v-if="error === LoginError.USER_EMAIL_PASSWORD_INVALID">{{
$t("Impossible to login, your email or password seems incorrect.")
}}</span>
<!-- TODO: Shouldn't we hide this information? -->
<span v-if="error === LoginError.USER_DOES_NOT_EXIST">{{
$t("No user account with this email was found. Maybe you made a typo?")
}}</span>
</b-message>
<form @submit="loginAction">
<b-field :label="$t('Email')">
<b-input aria-required="true" required type="email" v-model="credentials.email"/>
</b-field>
<b-field :label="$t('Password')">
<b-field :label="$t('Email')" label-for="email">
<b-input
aria-required="true"
required
id="email"
type="email"
v-model="credentials.email"
/>
</b-field>
<b-field :label="$t('Password')" label-for="password">
<b-input
aria-required="true"
id="password"
required
type="password"
password-reveal
v-model="credentials.password"
@@ -39,25 +58,27 @@
</b-field>
<p class="control has-text-centered">
<button class="button is-primary is-large">
{{ $t('Login') }}
</button>
<button class="button is-primary is-large">{{ $t("Login") }}</button>
</p>
<p class="control">
<router-link
class="button is-text"
:to="{ name: RouteName.SEND_PASSWORD_RESET, params: { email: credentials.email }}"
:to="{ name: RouteName.SEND_PASSWORD_RESET, params: { email: credentials.email } }"
>{{ $t("Forgot your password ?") }}</router-link
>
{{ $t('Forgot your password ?') }}
</router-link>
</p>
<p class="control" v-if="config && config.registrationsOpen">
<router-link
class="button is-text"
:to="{ name: RouteName.REGISTER, params: { default_email: credentials.email, default_password: credentials.password }}"
:to="{
name: RouteName.REGISTER,
params: {
default_email: credentials.email,
default_password: credentials.password,
},
}"
>{{ $t("Register") }}</router-link
>
{{ $t('Register') }}
</router-link>
</p>
</form>
</div>
@@ -66,18 +87,17 @@
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { LOGIN } from '@/graphql/auth';
import { validateEmailField, validateRequiredField } from '@/utils/validators';
import { initializeCurrentActor, NoIdentitiesException, saveUserData } from '@/utils/auth';
import { ILogin } from '@/types/login.model';
import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
import { onLogin } from '@/vue-apollo';
import { RouteName } from '@/router';
import { LoginErrorCode, LoginError } from '@/types/login-error-code.model';
import { ICurrentUser } from '@/types/current-user.model';
import { CONFIG } from '@/graphql/config';
import { IConfig } from '@/types/config.model';
import { Component, Prop, Vue } from "vue-property-decorator";
import { LOGIN } from "../../graphql/auth";
import { validateEmailField, validateRequiredField } from "../../utils/validators";
import { initializeCurrentActor, NoIdentitiesException, saveUserData } from "../../utils/auth";
import { ILogin } from "../../types/login.model";
import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from "../../graphql/user";
import RouteName from "../../router/name";
import { LoginErrorCode, LoginError } from "../../types/login-error-code.model";
import { ICurrentUser } from "../../types/current-user.model";
import { CONFIG } from "../../graphql/config";
import { IConfig } from "../../types/config.model";
@Component({
apollo: {
@@ -91,31 +111,36 @@ import { IConfig } from '@/types/config.model';
metaInfo() {
return {
// if no subcomponents specify a metaInfo.title, this title will be used
title: this.$t('Login on Mobilizon!') as string,
title: this.$t("Login on Mobilizon!") as string,
// all titles will be injected into this template
titleTemplate: '%s | Mobilizon',
titleTemplate: "%s | Mobilizon",
};
},
})
export default class Login extends Vue {
@Prop({ type: String, required: false, default: '' }) email!: string;
@Prop({ type: String, required: false, default: '' }) password!: string;
@Prop({ type: String, required: false, default: "" }) email!: string;
@Prop({ type: String, required: false, default: "" }) password!: string;
LoginErrorCode = LoginErrorCode;
LoginError = LoginError;
errorCode: LoginErrorCode | null = null;
config!: IConfig;
currentUser!: ICurrentUser;
RouteName = RouteName;
credentials = {
email: '',
password: '',
email: "",
password: "",
};
errors: string[] = [];
rules = {
required: validateRequiredField,
email: validateEmailField,
@@ -127,9 +152,9 @@ export default class Login extends Vue {
this.credentials.email = this.email;
this.credentials.password = this.password;
const query = this.$route.query;
this.errorCode = query['code'] as LoginErrorCode;
this.redirect = query['redirect'] as string;
const { query } = this.$route;
this.errorCode = query.code as LoginErrorCode;
this.redirect = query.redirect as string;
}
async loginAction(e: Event) {
@@ -146,7 +171,7 @@ export default class Login extends Vue {
},
});
if (data == null) {
throw new Error('Data is undefined');
throw new Error("Data is undefined");
}
saveUserData(data.login);
@@ -162,35 +187,36 @@ export default class Login extends Vue {
});
try {
await initializeCurrentActor(this.$apollo.provider.defaultClient);
} catch (e) {
if (e instanceof NoIdentitiesException) {
return await this.$router.push({
} catch (err) {
if (err instanceof NoIdentitiesException) {
return this.$router.push({
name: RouteName.REGISTER_PROFILE,
params: { email: this.currentUser.email, userAlreadyActivated: 'true' },
params: {
email: this.currentUser.email,
userAlreadyActivated: "true",
},
});
}
}
onLogin(this.$apollo);
if (this.redirect) {
await this.$router.push(this.redirect);
} else {
window.localStorage.setItem('welcome-back', 'yes');
await this.$router.push({ name: RouteName.HOME });
return this.$router.push(this.redirect);
}
window.localStorage.setItem("welcome-back", "yes");
return this.$router.push({ name: RouteName.HOME });
} catch (err) {
console.error(err);
err.graphQLErrors.forEach(({ message }) => {
err.graphQLErrors.forEach(({ message }: { message: string }) => {
this.errors.push(message);
});
return undefined;
}
}
}
</script>
<style lang="scss" scoped>
.container .columns {
margin: 1rem auto 3rem;
}
.container .columns {
margin: 1rem auto 3rem;
}
</style>

View File

@@ -1,10 +1,10 @@
<template>
<section class="section container columns is-mobile is-centered">
<div class="card column is-half-desktop">
<h1>
{{ $t('Password reset') }}
</h1>
<b-message title="Error" type="is-danger" v-for="error in errors" :key="error">{{ error }}</b-message>
<h1>{{ $t("Password reset") }}</h1>
<b-message title="Error" type="is-danger" v-for="error in errors" :key="error">{{
error
}}</b-message>
<form @submit="resetAction">
<b-field :label="$t('Password')">
<b-input
@@ -23,50 +23,50 @@
type="password"
password-reveal
minlength="6"
v-model="credentials.password_confirmation"
v-model="credentials.passwordConfirmation"
/>
</b-field>
<button class="button is-primary">
{{ $t('Reset my password') }}
</button>
<button class="button is-primary">{{ $t("Reset my password") }}</button>
</form>
</div>
</section>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { validateRequiredField } from '@/utils/validators';
import { RESET_PASSWORD } from '@/graphql/auth';
import { saveUserData } from '@/utils/auth';
import { ILogin } from '@/types/login.model';
import { RouteName } from '@/router';
import { Component, Prop, Vue } from "vue-property-decorator";
import { validateRequiredField } from "../../utils/validators";
import { RESET_PASSWORD } from "../../graphql/auth";
import { saveUserData } from "../../utils/auth";
import { ILogin } from "../../types/login.model";
import RouteName from "../../router/name";
@Component
export default class PasswordReset extends Vue {
@Prop({ type: String, required: true }) token!: string;
credentials = {
password: '',
password_confirmation: '',
} as { password: string; password_confirmation: string };
password: "",
passwordConfirmation: "",
} as { password: string; passwordConfirmation: string };
errors: string[] = [];
rules = {
password_length: (value: string) =>
value.length > 6 || 'Password must be at least 6 characters long',
passwordLength: (value: string) =>
value.length > 6 || "Password must be at least 6 characters long",
required: validateRequiredField,
password_equal: (value: string) =>
value === this.credentials.password || 'Passwords must be the same',
passwordEqual: (value: string) =>
value === this.credentials.password || "Passwords must be the same",
};
get samePasswords() {
return (
this.rules.password_length(this.credentials.password) === true &&
this.credentials.password === this.credentials.password_confirmation
this.rules.passwordLength(this.credentials.password) === true &&
this.credentials.password === this.credentials.passwordConfirmation
);
}
async resetAction(e) {
async resetAction(e: Event) {
e.preventDefault();
this.errors.splice(0);
@@ -79,14 +79,14 @@ export default class PasswordReset extends Vue {
},
});
if (data == null) {
throw new Error('Data is undefined');
throw new Error("Data is undefined");
}
saveUserData(data.resetPassword);
await this.$router.push({ name: RouteName.HOME });
} catch (err) {
console.error(err);
err.graphQLErrors.forEach(({ message }) => {
err.graphQLErrors.forEach(({ message }: { message: any }) => {
this.errors.push(message);
});
}

View File

@@ -2,54 +2,52 @@
<div class="section container">
<section class="hero">
<div class="hero-body">
<h1 class="title">
{{ $t('Register an account on Mobilizon!') }}
</h1>
<h1 class="title">{{ $t("Register an account on Mobilizon!") }}</h1>
</div>
</section>
<section>
<div class="columns">
<div class="column">
<div>
<subtitle>{{ $t('Features') }}</subtitle>
<subtitle>{{ $t("Features") }}</subtitle>
<div class="content">
<ul>
<li>{{ $t('Create and manage several identities from the same account') }}</li>
<li>{{ $t('Create, edit or delete events') }}</li>
<li>{{ $t('Register for an event by choosing one of your identities') }}</li>
<li>{{ $t("Create and manage several identities from the same account") }}</li>
<li>{{ $t("Create, edit or delete events") }}</li>
<li>{{ $t("Register for an event by choosing one of your identities") }}</li>
</ul>
</div>
</div>
<router-link :to="{ name: RouteName.ABOUT }">
{{ $t('Learn more') }}
</router-link>
<hr>
<router-link :to="{ name: RouteName.ABOUT }">{{ $t("Learn more") }}</router-link>
<hr />
<div class="content">
<subtitle>{{ $t('About this instance') }}</subtitle>
<subtitle>{{ $t("About this instance") }}</subtitle>
<div class="content">
<p>
{{ $t("Your local administrator resumed its policy:") }}
</p>
<p>{{ $t("Your local administrator resumed its policy:") }}</p>
<ul>
<li>{{ $t('Enjoy discovering Mobilizon!') }}</li>
<li>{{ $t("Enjoy discovering Mobilizon!") }}</li>
</ul>
</div>
<!-- <p>-->
<!-- {{ $t('Please read the full rules') }}-->
<!-- </p>-->
<!-- <p>-->
<!-- {{ $t('Please read the full rules') }}-->
<!-- </p>-->
</div>
</div>
<div class="column">
<b-message type="is-warning" v-if="config.registrationsWhitelist">{{ $t('Registrations are restricted by whitelisting.') }}</b-message>
<b-message type="is-warning" v-if="config.registrationsWhitelist">
{{ $t("Registrations are restricted by whitelisting.") }}
</b-message>
<form v-on:submit.prevent="submit()">
<b-field
:label="$t('Email')"
:type="errors.email ? 'is-danger' : null"
:message="errors.email"
label-for="email"
>
<b-input
aria-required="true"
required
id="email"
type="email"
v-model="credentials.email"
@blur="showGravatar = true"
@@ -61,10 +59,12 @@
:label="$t('Password')"
:type="errors.password ? 'is-danger' : null"
:message="errors.password"
label-for="password"
>
<b-input
aria-required="true"
required
id="password"
type="password"
password-reveal
minlength="6"
@@ -73,26 +73,25 @@
</b-field>
<p class="control has-text-centered">
<button class="button is-primary is-large">
{{ $t('Register') }}
</button>
<button class="button is-primary is-large">{{ $t("Register") }}</button>
</p>
<p class="control">
<router-link
class="button is-text"
:to="{ name: RouteName.RESEND_CONFIRMATION, params: { email: credentials.email }}"
:to="{ name: RouteName.RESEND_CONFIRMATION, params: { email: credentials.email } }"
>{{ $t("Didn't receive the instructions ?") }}</router-link
>
{{ $t("Didn't receive the instructions ?") }}
</router-link>
</p>
<p class="control">
<router-link
class="button is-text"
:to="{ name: RouteName.LOGIN, params: { email: credentials.email, password: credentials.password }}"
:to="{
name: RouteName.LOGIN,
params: { email: credentials.email, password: credentials.password },
}"
:disabled="sendingValidation"
>{{ $t("Login") }}</router-link
>
{{ $t('Login') }}
</router-link>
</p>
</form>
@@ -106,21 +105,21 @@
</template>
<script lang="ts">
import { CREATE_USER } from '@/graphql/user';
import { Component, Prop, Vue } from 'vue-property-decorator';
import { RouteName } from '@/router';
import { IConfig } from '@/types/config.model';
import { CONFIG } from '@/graphql/config';
import Subtitle from '@/components/Utils/Subtitle.vue';
import { Component, Prop, Vue } from "vue-property-decorator";
import { CREATE_USER } from "../../graphql/user";
import RouteName from "../../router/name";
import { IConfig } from "../../types/config.model";
import { CONFIG } from "../../graphql/config";
import Subtitle from "../../components/Utils/Subtitle.vue";
@Component({
components: { Subtitle },
metaInfo() {
return {
// if no subcomponents specify a metaInfo.title, this title will be used
title: this.$t('Register an account on Mobilizon!') as string,
title: this.$t("Register an account on Mobilizon!") as string,
// all titles will be injected into this template
titleTemplate: '%s | Mobilizon',
titleTemplate: "%s | Mobilizon",
};
},
apollo: {
@@ -128,18 +127,24 @@ import Subtitle from '@/components/Utils/Subtitle.vue';
},
})
export default class Register extends Vue {
@Prop({ type: String, required: false, default: '' }) email!: string;
@Prop({ type: String, required: false, default: '' }) password!: string;
@Prop({ type: String, required: false, default: "" }) email!: string;
@Prop({ type: String, required: false, default: "" }) password!: string;
credentials = {
email: this.email,
password: this.password,
locale: 'en',
locale: "en",
};
errors: object = {};
sendingValidation: boolean = false;
validationSent: boolean = false;
sendingValidation = false;
validationSent = false;
RouteName = RouteName;
config!: IConfig;
async submit() {
@@ -161,17 +166,17 @@ export default class Register extends Vue {
});
} catch (error) {
console.error(error);
this.errors = error.graphQLErrors.reduce((acc, error) => {
acc[error.details] = error.message;
this.errors = error.graphQLErrors.reduce((acc: { [key: string]: any }, localError: any) => {
acc[localError.details] = localError.message;
return acc;
}, {});
}, {});
}
}
}
</script>
<style lang="scss" scoped>
@import "../../variables";
@import "../../variables";
.avatar-enter-active {
transition: opacity 1s ease;
@@ -186,15 +191,15 @@ export default class Register extends Vue {
display: none;
}
.container .columns {
margin: 1rem auto 3rem;
}
.container .columns {
margin: 1rem auto 3rem;
}
h2.title {
color: $primary;
font-size: 2.5rem;
text-decoration: underline;
text-decoration-color: $secondary;
display: inline;
}
h2.title {
color: $primary;
font-size: 2.5rem;
text-decoration: underline;
text-decoration-color: $secondary;
display: inline;
}
</style>

View File

@@ -3,21 +3,26 @@
<div class="columns is-mobile is-centered">
<div class="column is-half-desktop">
<h1 class="title">
{{ $t('Resend confirmation email') }}
{{ $t("Resend confirmation email") }}
</h1>
<form v-if="!validationSent" @submit="resendConfirmationAction">
<b-field label="Email">
<b-input aria-required="true" required type="email" v-model="credentials.email"/>
<b-input aria-required="true" required type="email" v-model="credentials.email" />
</b-field>
<p class="control has-text-centered">
<b-button type="is-primary" native-type="submit">
{{ $t('Send me the confirmation email once again') }}
{{ $t("Send me the confirmation email once again") }}
</b-button>
</p>
</form>
<div v-else>
<b-message type="is-success" :closable="false" title="Success">
{{ $t('If an account with this email exists, we just sent another confirmation email to {email}', {email: credentials.email}) }}
{{
$t(
"If an account with this email exists, we just sent another confirmation email to {email}",
{ email: credentials.email }
)
}}
</b-message>
<b-message type="is-info">
{{ $t("Please check your spam folder if you didn't receive the email.") }}
@@ -29,25 +34,29 @@
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { validateEmailField, validateRequiredField } from '@/utils/validators';
import { RESEND_CONFIRMATION_EMAIL } from '@/graphql/auth';
import { Component, Prop, Vue } from "vue-property-decorator";
import { validateEmailField, validateRequiredField } from "../../utils/validators";
import { RESEND_CONFIRMATION_EMAIL } from "../../graphql/auth";
@Component
export default class ResendConfirmation extends Vue {
@Prop({ type: String, required: false, default: '' }) email!: string;
@Prop({ type: String, required: false, default: "" }) email!: string;
credentials = {
email: '',
email: "",
};
validationSent = false;
error = false;
state = {
email: {
status: null,
msg: '',
msg: "",
},
};
rules = {
required: validateRequiredField,
email: validateEmailField,
@@ -57,7 +66,7 @@ export default class ResendConfirmation extends Vue {
this.credentials.email = this.email;
}
async resendConfirmationAction(e) {
async resendConfirmationAction(e: Event) {
e.preventDefault();
this.error = false;
@@ -79,7 +88,7 @@ export default class ResendConfirmation extends Vue {
</script>
<style lang="scss" scoped>
.container .columns {
margin: 1rem auto 3rem;
}
</style>
.container .columns {
margin: 1rem auto 3rem;
}
</style>

View File

@@ -3,25 +3,30 @@
<div class="columns is-mobile is-centered">
<div class="column is-half-desktop">
<h1 class="title">
{{ $t('Password reset') }}
{{ $t("Password reset") }}
</h1>
<b-message
title="Error" type="is-danger" v-for="error in errors" :key="error" @close="removeError(error)">
<b-message
title="Error"
type="is-danger"
v-for="error in errors"
:key="error"
@close="removeError(error)"
>
{{ error }}
</b-message>
<form @submit="sendResetPasswordTokenAction" v-if="!validationSent">
<b-field label="Email">
<b-input aria-required="true" required type="email" v-model="credentials.email"/>
<b-input aria-required="true" required type="email" v-model="credentials.email" />
</b-field>
<p class="control has-text-centered">
<b-button type="is-primary" native-type="submit">
{{ $t('Send me an email to reset my password') }}
<b-button type="is-primary" native-type="submit">
{{ $t("Send me an email to reset my password") }}
</b-button>
</p>
</form>
<div v-else>
<b-message type="is-success" :closable="false" title="Success">
{{ $t('We just sent an email to {email}', {email: credentials.email}) }}
{{ $t("We just sent an email to {email}", { email: credentials.email }) }}
</b-message>
<b-message type="is-info">
{{ $t("Please check your spam folder if you didn't receive the email.") }}
@@ -33,23 +38,26 @@
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { validateEmailField, validateRequiredField } from '@/utils/validators';
import { SEND_RESET_PASSWORD } from '@/graphql/auth';
import { Component, Prop, Vue } from "vue-property-decorator";
import { validateEmailField, validateRequiredField } from "../../utils/validators";
import { SEND_RESET_PASSWORD } from "../../graphql/auth";
@Component
export default class SendPasswordReset extends Vue {
@Prop({ type: String, required: false, default: '' }) email!: string;
@Prop({ type: String, required: false, default: "" }) email!: string;
credentials = {
email: '',
email: "",
} as { email: string };
validationSent: boolean = false;
validationSent = false;
errors: string[] = [];
state = {
email: {
status: null,
msg: '',
msg: "",
} as { status: boolean | null; msg: string },
};
@@ -66,7 +74,7 @@ export default class SendPasswordReset extends Vue {
this.errors.splice(this.errors.indexOf(message));
}
async sendResetPasswordTokenAction(e) {
async sendResetPasswordTokenAction(e: Event) {
e.preventDefault();
try {
@@ -80,7 +88,7 @@ export default class SendPasswordReset extends Vue {
this.validationSent = true;
} catch (err) {
console.error(err);
err.graphQLErrors.forEach(({ message }) => {
err.graphQLErrors.forEach(({ message }: { message: string }) => {
if (this.errors.indexOf(message) < 0) {
this.errors.push(message);
}
@@ -92,7 +100,7 @@ export default class SendPasswordReset extends Vue {
this.state = {
email: {
status: null,
msg: '',
msg: "",
},
};
}
@@ -100,7 +108,7 @@ export default class SendPasswordReset extends Vue {
</script>
<style lang="scss" scoped>
.container .columns {
margin: 1rem auto 3rem;
}
.container .columns {
margin: 1rem auto 3rem;
}
</style>

View File

@@ -1,35 +1,33 @@
<template>
<section class="section container">
<h1 class="title" v-if="loading">
{{ $t('Your account is being validated') }}
</h1>
<h1 class="title" v-if="loading">{{ $t("Your account is being validated") }}</h1>
<div v-else>
<div v-if="failed">
<b-message :title="$t('Error while validating account')" type="is-danger">
{{ $t('Either the account is already validated, either the validation token is incorrect.') }}
{{
$t("Either the account is already validated, either the validation token is incorrect.")
}}
</b-message>
</div>
<h1 class="title" v-else>
{{ $t('Your account has been validated') }}
</h1>
<h1 class="title" v-else>{{ $t("Your account has been validated") }}</h1>
</div>
</section>
</template>
<script lang="ts">
import { VALIDATE_USER, UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
import { Component, Prop, Vue } from 'vue-property-decorator';
import { AUTH_USER_ID } from '@/constants';
import { RouteName } from '@/router';
import { saveUserData, changeIdentity } from '@/utils/auth';
import { ILogin } from '@/types/login.model';
import { ICurrentUserRole } from '@/types/current-user.model';
import { Component, Prop, Vue } from "vue-property-decorator";
import { VALIDATE_USER, UPDATE_CURRENT_USER_CLIENT } from "../../graphql/user";
import RouteName from "../../router/name";
import { saveUserData, changeIdentity } from "../../utils/auth";
import { ILogin } from "../../types/login.model";
import { ICurrentUserRole } from "../../types/current-user.model";
@Component
export default class Validate extends Vue {
@Prop({ type: String, required: true }) token!: string;
loading = true;
failed = false;
async created() {
@@ -48,7 +46,7 @@ export default class Validate extends Vue {
if (data) {
saveUserData(data.validateUser);
const user = data.validateUser.user;
const { user } = data.validateUser;
await this.$apollo.mutate({
mutation: UPDATE_CURRENT_USER_CLIENT,
@@ -63,10 +61,11 @@ export default class Validate extends Vue {
if (user.defaultActor) {
await changeIdentity(this.$apollo.provider.defaultClient, user.defaultActor);
await this.$router.push({ name: RouteName.HOME });
} else { // If the user didn't register any profile yet, let's create one for them
} else {
// If the user didn't register any profile yet, let's create one for them
await this.$router.push({
name: RouteName.REGISTER_PROFILE,
params: { email: user.email, userAlreadyActivated: 'true' },
params: { email: user.email, userAlreadyActivated: "true" },
});
}
}