Commit a6accf9b authored by quentin.vrel's avatar quentin.vrel
parents c340af94 8ab5e523
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<pwd-input id="password1" label="Mot de passe"/> <pwd-input id="password1" label="Mot de passe"/>
<pwd-input id="password2" label="Confirmer"/> <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-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"/> <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 { ...@@ -37,13 +38,10 @@ export default {
return { return {
showPwdError : false, showPwdError : false,
showBackError : false, showBackError : false,
showMailError : false,
} }
}, },
methods: { methods: {
updateShowPwdError: function(){
this.showPwdError = (document.getElementById('password1').value !== document.getElementById('password2').value);
},
updateShowBackError: function(){ updateShowBackError: function(){
this.showBackError = false; //TODO this.showBackError = false; //TODO
}, },
...@@ -52,6 +50,10 @@ export default { ...@@ -52,6 +50,10 @@ export default {
if (this.showPwdError) { if (this.showPwdError) {
return; return;
} }
this.showMailError = !validateEmail(document.getElementById('mail').value);
if (this.showMailError) {
return;
}
this.showBackError = false; //TODO this.showBackError = false; //TODO
if (this.showBackError) { if (this.showBackError) {
return; return;
...@@ -67,12 +69,12 @@ export default { ...@@ -67,12 +69,12 @@ export default {
'Content-Type': 'application/json;charset=utf-8' 'Content-Type': 'application/json;charset=utf-8'
}, },
body: JSON.stringify({ body: JSON.stringify({
login: "NEWUSER", login: document.getElementById('pseudo').value,
pwd: "hashedNEWUSERpwd", pwd: document.getElementById('password1').value,
avatar: "avatarnew.png", avatar: "default.png",
lastname: "NEW", lastname: "",
firstname: "USER", firstname: "",
mail: "new.user@free.fr" mail: document.getElementById('mail').value
}) })
}); //creating the content and sending the request }); //creating the content and sending the request
...@@ -84,6 +86,10 @@ export default { ...@@ -84,6 +86,10 @@ export default {
} }
} }
} }
function validateEmail (email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(String(email).toLowerCase());
}
</script> </script>
<style> <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