Add simplified user registration endpoint.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/6d7c58e6-0cd9-4f69-81f7-091dce31abab.jpg
This commit is contained in:
alphaeusmote
2025-04-08 21:10:03 +00:00
parent 4d9f92778b
commit a1cc112435
2 changed files with 83 additions and 6 deletions
+17 -6
View File
@@ -100,18 +100,29 @@ export default function AuthPage() {
},
});
// Register mutation
// Register mutation - using our simplified endpoint
const registerMutation = useMutation({
mutationFn: async (credentials: any) => {
const res = await apiRequest("POST", "/api/register", credentials);
return await res.json();
try {
const res = await apiRequest("POST", "/api/simple-register", credentials);
if (!res.ok) {
const errorData = await res.json();
throw new Error(errorData.message || "Registration failed");
}
return await res.json();
} catch (error) {
console.error("Registration error:", error);
throw error instanceof Error ? error : new Error("Unknown registration error");
}
},
onSuccess: (user) => {
onSuccess: (response) => {
toast({
title: "Registration successful",
description: `Welcome, ${user.username}!`,
description: response.message || `Welcome, ${response.username}!`,
});
navigate('/');
// Switch to login tab automatically
const loginTab = document.querySelector('[data-state="inactive"][data-value="login"]') as HTMLElement;
if (loginTab) loginTab.click();
},
onError: (error: Error) => {
toast({