Skip to content

Commit

Permalink
🧱 add very basic spam protection
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianjost committed Feb 11, 2024
1 parent 1282554 commit 0b0acb0
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/components/ContactCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
:with-error="true"
:error="error.message"
/>
<BaseInput
v-model="myName"
type="text"
label="Confirm my name"
name="myName"
placeholder="Adrian"
class="i-name"
:with-error="true"
:error="error.myName"
/>
<div class="actions">
<button
type="Submit"
Expand Down Expand Up @@ -90,11 +100,13 @@ export default {
return {
email: "",
message: "",
myName: "",
submitStatus: "ready",
copyStatus: "",
validate: {
email: false,
message: false,
myName: false,
},
};
},
Expand All @@ -106,6 +118,7 @@ export default {
const error = {
email: "",
message: "",
myName: "",
};
if (this.validate.email) {
if (!this.email) {
Expand All @@ -119,6 +132,11 @@ export default {
error.message = "An empty message? 🤨";
}
}
if (this.validate.myName) {
if (!this.myName.includes("Adrian")) {
error.myName = "Please confirm MY name.";
}
}
return error;
},
},
Expand All @@ -129,6 +147,9 @@ export default {
message: function (to) {
this.validate.message = true;
},
myName: function (to) {
this.validate.myName = true;
},
},
methods: {
copyToClipboard(text) {
Expand All @@ -155,8 +176,8 @@ export default {
});
},
sendMessage() {
this.validate = { email: true, message: true };
if (this.error.email || this.error.message) {
this.validate = { email: true, message: true, myName: true };
if (this.error.email || this.error.message || this.error.myName) {
return;
}
const mailData = {
Expand Down

0 comments on commit 0b0acb0

Please sign in to comment.