Tell me why?

This commit is contained in:
2022-12-25 14:01:00 +01:00
parent 869debe87e
commit 899edf8234
2 changed files with 5 additions and 2 deletions

View File

@@ -3,14 +3,16 @@ import type { RequestHandler } from './$types'
import { error } from '@sveltejs/kit'
export const POST = (async ({ request }) => {
const { email } = await request.json()
const data = await request.json()
const { email } = data
console.log('server:', data, email)
// No email
if (!email) {
throw error(400, { message: 'NO_EMAIL' })
}
// Invalid email
else if (!email || !email.match(/^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/)) {
if (!email.match(/^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/)) {
throw error(400, { message: 'INVALID_EMAIL' })
}