Improve user registration and access control for different account types
Adds admin user creation, role-based access, password confirmation, and professional profile fields to the user schema. 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
This commit is contained in:
+2892
File diff suppressed because it is too large
Load Diff
@@ -24,12 +24,20 @@ export const authController = {
|
||||
const saltRounds = 12;
|
||||
const hashedPassword = await bcrypt.hash(validatedData.password, saltRounds);
|
||||
|
||||
// Determine role - special handling for admin user
|
||||
let userRole = "standard";
|
||||
if (validatedData.email === "dev@adminlocal.com") {
|
||||
userRole = "admin";
|
||||
} else if (validatedData.role === "pro") {
|
||||
userRole = "pro";
|
||||
}
|
||||
|
||||
// Create user
|
||||
const user = await storage.createUser({
|
||||
username: validatedData.username,
|
||||
email: validatedData.email,
|
||||
password: hashedPassword,
|
||||
role: validatedData.role || 'standard',
|
||||
role: userRole,
|
||||
firstName: validatedData.firstName,
|
||||
lastName: validatedData.lastName,
|
||||
onboardingComplete: false,
|
||||
|
||||
@@ -3,6 +3,23 @@ import { relations } from "drizzle-orm";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
export const professionalTypeEnum = pgEnum("professional_type", [
|
||||
"doctor", "dentist", "therapist", "consultant", "lawyer",
|
||||
"accountant", "coach", "tutor", "other"
|
||||
]);
|
||||
|
||||
export const dayOfWeekEnum = pgEnum("day_of_week", [
|
||||
"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
|
||||
]);
|
||||
|
||||
export const appointmentStatusEnum = pgEnum("appointment_status", [
|
||||
"pending", "confirmed", "cancelled", "completed", "no_show"
|
||||
]);
|
||||
|
||||
export const connectionStatusEnum = pgEnum("connection_status", [
|
||||
"pending", "accepted", "blocked"
|
||||
]);
|
||||
|
||||
// Users table
|
||||
export const users = pgTable("users", {
|
||||
id: serial("id").primaryKey(),
|
||||
@@ -15,6 +32,21 @@ export const users = pgTable("users", {
|
||||
onboardingComplete: boolean("onboarding_complete").default(false),
|
||||
voiceEnabled: boolean("voice_enabled").default(true),
|
||||
ttsEnabled: boolean("tts_enabled").default(true),
|
||||
|
||||
// Professional Profile Fields
|
||||
isProfessional: boolean("is_professional").default(false).notNull(),
|
||||
professionalType: professionalTypeEnum("professional_type"),
|
||||
businessName: varchar("business_name", { length: 255 }),
|
||||
bio: text("bio"),
|
||||
specializations: text("specializations"), // JSON array as text
|
||||
phoneNumber: varchar("phone_number", { length: 20 }),
|
||||
address: text("address"),
|
||||
|
||||
// Social & Discovery
|
||||
isPublicProfile: boolean("is_public_profile").default(false).notNull(),
|
||||
allowAppointmentBooking: boolean("allow_appointment_booking").default(false).notNull(),
|
||||
profileImageUrl: varchar("profile_image_url", { length: 500 }),
|
||||
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
updatedAt: timestamp("updated_at").defaultNow(),
|
||||
});
|
||||
@@ -196,6 +228,7 @@ export const loginSchema = z.object({
|
||||
});
|
||||
|
||||
export const registerSchema = insertUserSchema.extend({
|
||||
password: z.string().min(6, "Password must be at least 6 characters"),
|
||||
confirmPassword: z.string(),
|
||||
}).refine((data) => data.password === data.confirmPassword, {
|
||||
message: "Passwords don't match",
|
||||
|
||||
Reference in New Issue
Block a user