Commit c1bd8146 authored by Zohten's avatar Zohten

added comments

parent a6accf9b
...@@ -46,21 +46,30 @@ export default { ...@@ -46,21 +46,30 @@ export default {
this.showBackError = false; //TODO this.showBackError = false; //TODO
}, },
onSubmit: async function(){ onSubmit: async function(){
// If we press back, we go back
if (event.submitter.id=='back') {
this.$router.push('/');
}
// Test if password match the confirm password
this.showPwdError = (document.getElementById('password1').value !== document.getElementById('password2').value); this.showPwdError = (document.getElementById('password1').value !== document.getElementById('password2').value);
if (this.showPwdError) { if (this.showPwdError) {
return; return;
} }
// Test if mail is valid
this.showMailError = !validateEmail(document.getElementById('mail').value); this.showMailError = !validateEmail(document.getElementById('mail').value);
if (this.showMailError) { if (this.showMailError) {
return; return;
} }
// Test if Email exist/Pseudo exist
this.showBackError = false; //TODO this.showBackError = false; //TODO
if (this.showBackError) { if (this.showBackError) {
return; return;
} }
if (event.submitter.id=='back') {
this.$router.push('/'); // Post new user if all tests are ok
}
if (event.submitter.id=='validate') { if (event.submitter.id=='validate') {
let request = await fetch('http://localhost/index.php/user', let request = await fetch('http://localhost/index.php/user',
{ {
...@@ -86,6 +95,7 @@ export default { ...@@ -86,6 +95,7 @@ export default {
} }
} }
} }
// Function to check if the str email is valide (true if this is the case)
function validateEmail (email) { function validateEmail (email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(String(email).toLowerCase()); return re.test(String(email).toLowerCase());
......
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