Email validation

This commit is contained in:
Maximilian Leopold 2019-06-06 14:16:46 +02:00
parent c6c35dbd11
commit e8809630ef
2 changed files with 39 additions and 9 deletions

View File

@ -98,7 +98,7 @@
methods: {
validateEmail(email) {
//var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
let re = new RegExp('^[a-zA-Z0-9.!#$%&\'*+/=?^_`{|}~-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$');
let re = new RegExp('(?:[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])');
return re.test(String(email).toLowerCase());
},
register: function () {

View File

@ -42,7 +42,7 @@
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label
type="text"
label="Username eingeben"
label="Email eingeben"
unelevated color="negative"
v-model="deleteUser"
></q-input>
@ -192,14 +192,38 @@
if(this.deleteUser != null){
let username = this.deleteUser;
let token = JSON.parse(localStorage.getItem('userToken')).token;
if(this.validateEmail(this.email)) {
this.$axios.put('/api/resetSingleUser',null, {params: {token, username}})
.then((response) => {
console.log("Rankinglist: ");
console.log(response.data);
this.fetchRankinglist();
}).catch((error) => {
})
this.$axios.put('/api/resetSingleUser', null, {params: {token, username}})
.then((response) => {
console.log("Rankinglist: ");
console.log(response.data);
this.fetchRankinglist();
}).catch((error) => {
let msg;
let title;
if (error.response) {
title = "Bitte Eingaben überprüfen!";
msg = error.response.data;
} else if (error.request) {
title = "Verbindungsfehler!";
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
console.log(error.request);
} else {
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
})
}else{
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Bitte geben Sie eine gültige Email ein",
title: "Ungültige Email",
color: "negative"
});
}
} else {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Zum zurücksetzen der Punkte eines Nutzers gib bitte einen Usernamen ein",
@ -209,6 +233,12 @@
}
},
validateEmail(email) {
//var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
let re = new RegExp('(?:[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])');
return re.test(String(email).toLowerCase());
},
}
}
</script>