From 1d2adb38ebfda98be66accd633938f2c7465214b Mon Sep 17 00:00:00 2001 From: ghaddaditw <40211818-ghaddaditw@users.noreply.replit.com> Date: Fri, 30 May 2025 17:23:53 +0000 Subject: [PATCH] Improve user registration and data handling for new features Improves password hashing and adds schema relations for appointments, connections, reviews, and availability. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 556aa286-edd2-4cea-8583-f4fc3cfd119b Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/81470e0d-8ae8-4335-9301-cd9a69e670fa/8e77b04a-d19f-45af-9f57-84d64672fc92.jpg --- server/controllers/authController.ts | 2 +- shared/schema.ts | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/server/controllers/authController.ts b/server/controllers/authController.ts index 84f2b36..7a713ee 100644 --- a/server/controllers/authController.ts +++ b/server/controllers/authController.ts @@ -22,7 +22,7 @@ export const authController = { // Hash password const saltRounds = 12; - const hashedPassword = await bcrypt.hash(validatedData.password, saltRounds); + const hashedPassword = await bcrypt.hash(validatedData.password as string, saltRounds); // Determine role - special handling for admin user let userRole = "standard"; diff --git a/shared/schema.ts b/shared/schema.ts index 6b7c4f7..423ab73 100644 --- a/shared/schema.ts +++ b/shared/schema.ts @@ -1,4 +1,4 @@ -import { pgTable, text, serial, integer, boolean, timestamp, numeric, varchar, uuid, json } from "drizzle-orm/pg-core"; +import { pgTable, text, serial, integer, boolean, timestamp, numeric, varchar, uuid, json, pgEnum, time, decimal } from "drizzle-orm/pg-core"; import { relations } from "drizzle-orm"; import { createInsertSchema, createSelectSchema } from "drizzle-zod"; import { z } from "zod"; @@ -167,6 +167,26 @@ export const userPreferencesRelations = relations(userPreferences, ({ one }) => user: one(users, { fields: [userPreferences.userId], references: [users.id] }), })); +export const availabilityRelations = relations(availability, ({ one }) => ({ + professional: one(users, { fields: [availability.professionalId], references: [users.id] }), +})); + +export const appointmentsRelations = relations(appointments, ({ one }) => ({ + professional: one(users, { fields: [appointments.professionalId], references: [users.id] }), + client: one(users, { fields: [appointments.clientId], references: [users.id] }), +})); + +export const connectionsRelations = relations(connections, ({ one }) => ({ + requester: one(users, { fields: [connections.requesterId], references: [users.id] }), + receiver: one(users, { fields: [connections.receiverId], references: [users.id] }), +})); + +export const reviewsRelations = relations(reviews, ({ one }) => ({ + professional: one(users, { fields: [reviews.professionalId], references: [users.id] }), + client: one(users, { fields: [reviews.clientId], references: [users.id] }), + appointment: one(appointments, { fields: [reviews.appointmentId], references: [appointments.id] }), +})); + // Zod schemas for validation export const insertUserSchema = createInsertSchema(users).omit({ id: true,