diff --git a/.turbo/daemon/53b0054db79f7114-turbo.log.2026-04-05 b/.turbo/daemon/53b0054db79f7114-turbo.log.2026-04-05 new file mode 100644 index 0000000..e69de29 diff --git a/.turbo/daemon/53b0054db79f7114-turbo.log.2026-04-08 b/.turbo/daemon/53b0054db79f7114-turbo.log.2026-04-08 new file mode 100644 index 0000000..e69de29 diff --git a/.turbo/preferences/tui.json b/.turbo/preferences/tui.json index f46ddd7..efb3625 100644 --- a/.turbo/preferences/tui.json +++ b/.turbo/preferences/tui.json @@ -1,4 +1,4 @@ { "is_task_list_visible": true, - "active_task": "backend#dev" + "active_task": "frontend#dev" } \ No newline at end of file diff --git a/apps/Backend/.env b/apps/Backend/.env index aa4e86c..e357679 100755 --- a/apps/Backend/.env +++ b/apps/Backend/.env @@ -2,8 +2,8 @@ NODE_ENV="development" HOST=0.0.0.0 PORT=5000 # FRONTEND_URLS=http://localhost:3000,http://192.168.1.8:3000 -# FRONTEND_URLS=http://localhost:3000 -FRONTEND_URLS=http://192.168.1.37:3000 +FRONTEND_URLS=http://localhost:3000 +# FRONTEND_URLS=http://192.168.1.37:3000 SELENIUM_AGENT_BASE_URL=http://localhost:5002 JWT_SECRET = 'dentalsecret' DB_HOST=localhost diff --git a/apps/Backend/src/routes/users.ts b/apps/Backend/src/routes/users.ts index baaa7de..3e0f3a3 100755 --- a/apps/Backend/src/routes/users.ts +++ b/apps/Backend/src/routes/users.ts @@ -34,6 +34,21 @@ router.get("/", async (req: Request, res: Response): Promise => { } }); +// GET: List all users (admin only) +router.get("/list", async (req: Request, res: Response): Promise => { + try { + if (req.user?.username !== "admin") { + return res.status(403).json({ error: "Forbidden" }); + } + const users = await storage.getUsers(1000, 0); + const safeUsers = users.map(({ password, ...u }) => u); + res.json(safeUsers); + } catch (error) { + console.error(error); + res.status(500).send("Failed to fetch users"); + } +}); + // GET: User by ID router.get("/:id", async (req: Request, res: Response): Promise => { try { @@ -55,10 +70,18 @@ router.get("/:id", async (req: Request, res: Response): Promise => { }); // POST: Create new user -router.post("/", async (req: Request, res: Response) => { +router.post("/", async (req: Request, res: Response): Promise => { try { + if (req.user?.username !== "admin") { + return res.status(403).json({ error: "Forbidden" }); + } const input = userCreateSchema.parse(req.body); - const newUser = await storage.createUser(input); + const existing = await storage.getUserByUsername(input.username as string); + if (existing) { + return res.status(400).json({ error: "Username already exists" }); + } + const hashed = await hashPassword(input.password as string); + const newUser = await storage.createUser({ ...input, password: hashed }); const { password, ...safeUser } = newUser; res.status(201).json(safeUser); } catch (err) { diff --git a/apps/Frontend/.env b/apps/Frontend/.env index 758647e..8396691 100755 --- a/apps/Frontend/.env +++ b/apps/Frontend/.env @@ -1,5 +1,5 @@ NODE_ENV=development HOST=0.0.0.0 PORT=3000 -VITE_API_BASE_URL_BACKEND= -# VITE_API_BASE_URL_BACKEND=http://localhost:5000 \ No newline at end of file +# VITE_API_BASE_URL_BACKEND=http://192.168.1.37:5000 +VITE_API_BASE_URL_BACKEND=http://localhost:5000 \ No newline at end of file diff --git a/apps/Frontend/src/App.tsx b/apps/Frontend/src/App.tsx index bea2914..465a3f1 100755 --- a/apps/Frontend/src/App.tsx +++ b/apps/Frontend/src/App.tsx @@ -41,7 +41,7 @@ function Router() { component={() => } /> } /> - } /> + } adminOnly /> } /> [ @@ -82,6 +85,7 @@ export function Sidebar() { name: "Settings", path: "/settings", icon: , + adminOnly: true, }, ], [] @@ -107,7 +111,7 @@ export function Sidebar() { >