Tell me why?
This commit is contained in:
@@ -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' })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user