diff options
| author | schererleander <leander@leander-scherer.de> | 2024-08-09 11:36:29 +0200 |
|---|---|---|
| committer | schererleander <leander@leander-scherer.de> | 2024-08-09 11:36:29 +0200 |
| commit | aa02bff4a1d36dacd4ea42e8e56191a7bdca5fb1 (patch) | |
| tree | 4cf25a4d79ec4f059aa8da2b4d5b9f9528900f96 | |
| parent | 8f5e7422b937c20a4b7c10b8f0f70821ee982cc1 (diff) | |
feat: add email validation
| -rw-r--r-- | server.js | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -58,6 +58,10 @@ app.post("/api/password/signin", async (req, res) => { return res.status(401).send("Invalid credentials"); } + if(!validateEmail(email)) { + return res.status(401).send("Invalid email"); + } + const [users] = await con.query( "SELECT * FROM users WHERE email = ?", [email] @@ -95,4 +99,9 @@ app.get("/user/:uuid", async (req, res) => { console.error(error) return res.status(500).send("Server error") } -})
\ No newline at end of file +}) + +function validateEmail(email) { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return emailRegex.test(email); +}
\ No newline at end of file |
