Commit a6accf9b authored by quentin.vrel's avatar quentin.vrel
parents c340af94 8ab5e523
......@@ -8,6 +8,7 @@
<pwd-input id="password1" label="Mot de passe"/>
<pwd-input id="password2" label="Confirmer"/>
<error-message id="error-password" errormessage="Les mots de passe ne correspondent pas." v-show="this.showPwdError"/>
<error-message id="error-mail" errormessage="Le mail rentré n'est pas valide" v-show="this.showMailError"/>
<error-message id="error-back" errormessage="Cet email ou ce pseudo est déjà pris." v-show="this.showBackError"/>
......@@ -37,13 +38,10 @@ export default {
return {
showPwdError : false,
showBackError : false,
showMailError : false,
}
},
methods: {
updateShowPwdError: function(){
this.showPwdError = (document.getElementById('password1').value !== document.getElementById('password2').value);
},
updateShowBackError: function(){
this.showBackError = false; //TODO
},
......@@ -52,6 +50,10 @@ export default {
if (this.showPwdError) {
return;
}
this.showMailError = !validateEmail(document.getElementById('mail').value);
if (this.showMailError) {
return;
}
this.showBackError = false; //TODO
if (this.showBackError) {
return;
......@@ -67,12 +69,12 @@ export default {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify({
login: "NEWUSER",
pwd: "hashedNEWUSERpwd",
avatar: "avatarnew.png",
lastname: "NEW",
firstname: "USER",
mail: "new.user@free.fr"
login: document.getElementById('pseudo').value,
pwd: document.getElementById('password1').value,
avatar: "default.png",
lastname: "",
firstname: "",
mail: document.getElementById('mail').value
})
}); //creating the content and sending the request
......@@ -84,6 +86,10 @@ export default {
}
}
}
function validateEmail (email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(String(email).toLowerCase());
}
</script>
<style>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment