2017-12-07 22:32:23 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
|
|
|
|
<div id='SIGNUP-FORM' :class='gstore.signupform ? "active" : ""'>
|
|
|
|
|
|
|
|
|
|
<!-- Header -->
|
|
|
|
|
<div class='head'>
|
|
|
|
|
<span>Création d'un compte</span>
|
|
|
|
|
<i></i>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Body -->
|
|
|
|
|
<div class='body'>
|
|
|
|
|
<form @submit.prevent='create_account'>
|
|
|
|
|
<label for='username'>Nom d'utilisateur</label>
|
|
|
|
|
<input :class='err_username ? "err" : ""' v-model='username_val' type='text' id='username'>
|
|
|
|
|
<label for='mail'>Adresse mail</label>
|
|
|
|
|
<input :class='err_mail ? "err" : ""' v-model='mail_val' type='email' id='mail'>
|
|
|
|
|
<label for='password'>Mot de passe</label>
|
|
|
|
|
<input v-model='password_val' type='password' id='password'>
|
|
|
|
|
<p v-if='err_username || err_mail || err_unknow' id='msg-err'>{{ err_message }}</p>
|
|
|
|
|
<button id='btn-create-account'>Créer mon compte</button>
|
2017-12-08 00:22:03 +00:00
|
|
|
|
<p @click='redirect_login' id='membre'>Déjà membre ? Connectez-vous !</p>
|
2017-12-07 22:32:23 +00:00
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
name: 'SIGNUP_FORM',
|
|
|
|
|
data(){
|
|
|
|
|
return {
|
|
|
|
|
gstore: gstore.data,
|
|
|
|
|
username_val: '',
|
|
|
|
|
mail_val: '',
|
|
|
|
|
password_val: '',
|
|
|
|
|
err_username: false,
|
|
|
|
|
err_mail: false,
|
|
|
|
|
err_unknow: false,
|
|
|
|
|
err_message: ''
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
create_account() {
|
2017-12-08 01:35:16 +00:00
|
|
|
|
const const_username = this.username_val;
|
|
|
|
|
const const_mail = this.mail_val;
|
|
|
|
|
const const_password = this.password_val;
|
|
|
|
|
|
2017-12-07 22:32:23 +00:00
|
|
|
|
let request = {
|
2017-12-08 01:35:16 +00:00
|
|
|
|
username: const_username,
|
|
|
|
|
mail: const_mail,
|
|
|
|
|
password: const_password
|
2017-12-07 22:32:23 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
api.call("POST user/signup", request, function (response) {
|
|
|
|
|
/* (1) Check if is there an error and display theme that goes with */
|
2017-12-08 01:35:16 +00:00
|
|
|
|
if (response.error == 17 && response.ErrorDescription.indexOf('mail') !== -1) {
|
2017-12-07 22:32:23 +00:00
|
|
|
|
this.err_username = false;
|
2017-12-08 01:35:16 +00:00
|
|
|
|
this.err_mail = true;
|
2017-12-07 22:32:23 +00:00
|
|
|
|
this.err_unknow = false;
|
|
|
|
|
this.err_message = 'Le mail est invalide';
|
|
|
|
|
}
|
2017-12-08 01:35:16 +00:00
|
|
|
|
else if (response.error == 17 && response.ErrorDescription.indexOf('username') !== -1) {
|
|
|
|
|
this.err_username = true;
|
|
|
|
|
this.err_mail = false;
|
|
|
|
|
this.err_unknow = false;
|
|
|
|
|
this.err_message = 'Le nom d\'utilisateur a des caractères invalides';
|
|
|
|
|
}
|
2017-12-07 22:32:23 +00:00
|
|
|
|
else if (response.error == 29) {
|
|
|
|
|
this.err_username = true;
|
2017-12-08 01:35:16 +00:00
|
|
|
|
this.err_mail = true;
|
2017-12-07 22:32:23 +00:00
|
|
|
|
this.err_unknow = false;
|
|
|
|
|
this.err_message = 'Le nom d\'utilisateur ou le mail est déjà pris';
|
|
|
|
|
}
|
|
|
|
|
else if (!response.registered) {
|
|
|
|
|
this.err_username = false;
|
2017-12-08 01:35:16 +00:00
|
|
|
|
this.err_mail = false;
|
2017-12-07 22:32:23 +00:00
|
|
|
|
this.err_unknow = true;
|
|
|
|
|
this.err_message = 'Impossible de créer le compte pour le moment, veuillez réessayer plus tard';
|
|
|
|
|
}
|
|
|
|
|
/* (2) Close the sign up form authentication */
|
|
|
|
|
else {
|
2017-12-08 01:35:16 +00:00
|
|
|
|
infobox._display('Inscription terminée ! Connexion en cours ...', 'info', 3000);
|
2017-12-08 00:22:03 +00:00
|
|
|
|
|
|
|
|
|
let request = {
|
2017-12-08 01:35:16 +00:00
|
|
|
|
username: const_username,
|
|
|
|
|
password: const_password
|
2017-12-08 00:22:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
api.call("POST user/login", request, function (response) {
|
|
|
|
|
document.location = '';
|
|
|
|
|
});
|
2017-12-07 22:32:23 +00:00
|
|
|
|
}
|
|
|
|
|
}.bind(this));
|
2017-12-08 00:22:03 +00:00
|
|
|
|
},
|
|
|
|
|
redirect_login() {
|
|
|
|
|
this.gstore.signupform = false;
|
|
|
|
|
this.gstore.loginform = true;
|
2017-12-07 22:32:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|