2019-01-21 15:08:22 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<section class="hero">
|
|
|
|
<div class="hero-body">
|
|
|
|
<h1 class="title">
|
2019-09-12 11:34:01 +02:00
|
|
|
{{ $t('Register an account on Mobilizon!') }}
|
2019-01-21 15:08:22 +01:00
|
|
|
</h1>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<div class="container">
|
|
|
|
<div class="columns is-mobile">
|
|
|
|
<div class="column">
|
|
|
|
<form v-if="!validationSent">
|
2019-01-29 11:02:32 +01:00
|
|
|
<b-field
|
2019-09-23 10:26:38 +02:00
|
|
|
:label="$t('Username')"
|
2019-01-29 11:02:32 +01:00
|
|
|
:type="errors.preferred_username ? 'is-danger' : null"
|
|
|
|
:message="errors.preferred_username"
|
|
|
|
>
|
|
|
|
<b-field>
|
|
|
|
<b-input
|
|
|
|
aria-required="true"
|
|
|
|
required
|
|
|
|
expanded
|
|
|
|
v-model="person.preferredUsername"
|
|
|
|
/>
|
|
|
|
<p class="control">
|
|
|
|
<span class="button is-static">@{{ host }}</span>
|
|
|
|
</p>
|
|
|
|
</b-field>
|
2019-01-21 15:08:22 +01:00
|
|
|
</b-field>
|
|
|
|
|
2019-09-12 11:34:01 +02:00
|
|
|
<b-field :label="$t('Displayed name')">
|
2019-01-29 11:02:32 +01:00
|
|
|
<b-input v-model="person.name"/>
|
2019-01-21 15:08:22 +01:00
|
|
|
</b-field>
|
|
|
|
|
2019-09-12 11:34:01 +02:00
|
|
|
<b-field :label="$t('Description')">
|
2019-01-29 11:02:32 +01:00
|
|
|
<b-input type="textarea" v-model="person.summary"/>
|
2019-01-21 15:08:22 +01:00
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field grouped>
|
|
|
|
<div class="control">
|
|
|
|
<button type="button" class="button is-primary" @click="submit()">
|
2019-09-12 11:34:01 +02:00
|
|
|
{{ $t('Create my profile') }}
|
2019-01-21 15:08:22 +01:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</b-field>
|
|
|
|
</form>
|
|
|
|
|
2019-01-30 15:54:21 +01:00
|
|
|
<div v-if="validationSent && !userAlreadyActivated">
|
2019-01-21 15:08:22 +01:00
|
|
|
<b-message title="Success" type="is-success">
|
2019-01-29 11:02:32 +01:00
|
|
|
<h2 class="title">
|
2019-09-12 11:34:01 +02:00
|
|
|
{{ $t('Your account is nearly ready, {username}', { username: person.preferredUsername }) }}
|
2019-01-21 15:08:22 +01:00
|
|
|
</h2>
|
2019-01-29 11:02:32 +01:00
|
|
|
<p>
|
2019-09-12 11:34:01 +02:00
|
|
|
{{ $t('A validation email was sent to {email}', { email }) }}
|
2019-01-29 11:02:32 +01:00
|
|
|
</p>
|
2019-01-21 15:08:22 +01:00
|
|
|
<p>
|
2019-09-12 11:34:01 +02:00
|
|
|
{{ $t('Before you can login, you need to click on the link inside it to validate your account') }}
|
2019-01-21 15:08:22 +01:00
|
|
|
</p>
|
|
|
|
</b-message>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-03-22 10:57:14 +01:00
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
2019-04-26 15:22:16 +02:00
|
|
|
import { IPerson } from '@/types/actor';
|
2019-03-22 10:57:14 +01:00
|
|
|
import { REGISTER_PERSON } from '@/graphql/actor';
|
|
|
|
import { MOBILIZON_INSTANCE_HOST } from '@/api/_entrypoint';
|
|
|
|
import { RouteName } from '@/router';
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-02-22 14:55:47 +01:00
|
|
|
@Component
|
2019-01-21 15:08:22 +01:00
|
|
|
export default class Register extends Vue {
|
2019-01-30 15:54:21 +01:00
|
|
|
@Prop({ type: String, required: true }) email!: string;
|
|
|
|
@Prop({ type: Boolean, required: false, default: false }) userAlreadyActivated!: boolean;
|
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
host?: string = MOBILIZON_INSTANCE_HOST;
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-01-29 11:02:32 +01:00
|
|
|
person: IPerson = {
|
2019-02-22 14:55:47 +01:00
|
|
|
preferredUsername: '',
|
|
|
|
name: '',
|
|
|
|
summary: '',
|
|
|
|
url: '',
|
2019-01-29 11:02:32 +01:00
|
|
|
suspended: false,
|
2019-05-22 14:12:11 +02:00
|
|
|
avatar: null,
|
|
|
|
banner: null,
|
2019-01-29 11:02:32 +01:00
|
|
|
domain: null,
|
2019-03-21 20:23:42 +01:00
|
|
|
feedTokens: [],
|
|
|
|
goingToEvents: [],
|
2019-01-29 11:02:32 +01:00
|
|
|
};
|
|
|
|
errors: object = {};
|
2019-01-21 15:08:22 +01:00
|
|
|
validationSent: boolean = false;
|
2019-01-29 11:02:32 +01:00
|
|
|
sendingValidation: boolean = false;
|
2019-01-21 15:08:22 +01:00
|
|
|
|
|
|
|
async submit() {
|
|
|
|
try {
|
2019-01-29 11:02:32 +01:00
|
|
|
this.sendingValidation = true;
|
|
|
|
this.errors = {};
|
2019-01-21 15:08:22 +01:00
|
|
|
await this.$apollo.mutate({
|
2019-01-29 11:02:32 +01:00
|
|
|
mutation: REGISTER_PERSON,
|
2019-03-22 10:57:14 +01:00
|
|
|
variables: Object.assign({ email: this.email }, this.person),
|
2019-01-21 15:08:22 +01:00
|
|
|
});
|
2019-01-29 11:02:32 +01:00
|
|
|
this.validationSent = true;
|
2019-01-30 15:54:21 +01:00
|
|
|
|
|
|
|
if (this.userAlreadyActivated) {
|
2019-02-22 14:55:47 +01:00
|
|
|
this.$router.push({ name: RouteName.HOME });
|
2019-01-30 15:54:21 +01:00
|
|
|
}
|
2019-01-21 15:08:22 +01:00
|
|
|
} catch (error) {
|
2019-01-29 11:02:32 +01:00
|
|
|
this.errors = error.graphQLErrors.reduce((acc, error) => {
|
|
|
|
acc[error.details] = error.message;
|
|
|
|
return acc;
|
2019-03-22 10:57:14 +01:00
|
|
|
}, {});
|
2019-01-21 15:08:22 +01:00
|
|
|
console.error(error);
|
2019-01-29 11:02:32 +01:00
|
|
|
console.error(this.errors);
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.avatar-enter-active {
|
|
|
|
transition: opacity 1s ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
.avatar-enter,
|
|
|
|
.avatar-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.avatar-leave {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|