Prettier format pending files
This commit is contained in:
parent
2df17dc8ec
commit
a4d2466bd1
2 changed files with 41 additions and 17 deletions
|
|
@ -560,15 +560,18 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
if (data.user) {
|
if (data.user) {
|
||||||
try {
|
try {
|
||||||
// Try to send via custom SMTP server
|
// Try to send via custom SMTP server
|
||||||
const verifyResponse = await fetch("/api/auth/send-verification-email", {
|
const verifyResponse = await fetch(
|
||||||
method: "POST",
|
"/api/auth/send-verification-email",
|
||||||
headers: { "Content-Type": "application/json" },
|
{
|
||||||
body: JSON.stringify({
|
method: "POST",
|
||||||
email,
|
headers: { "Content-Type": "application/json" },
|
||||||
redirectTo,
|
body: JSON.stringify({
|
||||||
fullName: metadata.full_name || null,
|
email,
|
||||||
}),
|
redirectTo,
|
||||||
});
|
fullName: metadata.full_name || null,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const verifyPayload = await verifyResponse.json().catch(() => ({}));
|
const verifyPayload = await verifyResponse.json().catch(() => ({}));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -541,17 +541,34 @@ export function createServer() {
|
||||||
if (!payload.author_id) {
|
if (!payload.author_id) {
|
||||||
return res.status(400).json({ error: "author_id is required" });
|
return res.status(400).json({ error: "author_id is required" });
|
||||||
}
|
}
|
||||||
if (!payload.title || typeof payload.title !== "string" || !payload.title.trim()) {
|
if (
|
||||||
return res.status(400).json({ error: "title is required and must be a non-empty string" });
|
!payload.title ||
|
||||||
|
typeof payload.title !== "string" ||
|
||||||
|
!payload.title.trim()
|
||||||
|
) {
|
||||||
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({ error: "title is required and must be a non-empty string" });
|
||||||
}
|
}
|
||||||
if (!payload.content || typeof payload.content !== "string" || !payload.content.trim()) {
|
if (
|
||||||
return res.status(400).json({ error: "content is required and must be a non-empty string" });
|
!payload.content ||
|
||||||
|
typeof payload.content !== "string" ||
|
||||||
|
!payload.content.trim()
|
||||||
|
) {
|
||||||
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({
|
||||||
|
error: "content is required and must be a non-empty string",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate author_id is a valid UUID format
|
// Validate author_id is a valid UUID format
|
||||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
const uuidRegex =
|
||||||
|
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||||
if (!uuidRegex.test(String(payload.author_id))) {
|
if (!uuidRegex.test(String(payload.author_id))) {
|
||||||
return res.status(400).json({ error: "author_id must be a valid UUID" });
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({ error: "author_id must be a valid UUID" });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -573,7 +590,9 @@ export function createServer() {
|
||||||
title: String(payload.title).trim(),
|
title: String(payload.title).trim(),
|
||||||
content: String(payload.content).trim(),
|
content: String(payload.content).trim(),
|
||||||
category: payload.category ? String(payload.category).trim() : null,
|
category: payload.category ? String(payload.category).trim() : null,
|
||||||
tags: Array.isArray(payload.tags) ? payload.tags.map((t: any) => String(t).trim()) : [],
|
tags: Array.isArray(payload.tags)
|
||||||
|
? payload.tags.map((t: any) => String(t).trim())
|
||||||
|
: [],
|
||||||
is_published: payload.is_published ?? true,
|
is_published: payload.is_published ?? true,
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
|
|
@ -585,7 +604,9 @@ export function createServer() {
|
||||||
message: error.message,
|
message: error.message,
|
||||||
details: (error as any).details,
|
details: (error as any).details,
|
||||||
});
|
});
|
||||||
return res.status(500).json({ error: error.message || "Failed to create post" });
|
return res
|
||||||
|
.status(500)
|
||||||
|
.json({ error: error.message || "Failed to create post" });
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json(data);
|
res.json(data);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue