Add authentication check and require user ID for story creation
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ import { stories, pages, type Story, type Page } from './schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { generateComicSlug } from './slug-generator';
|
||||
|
||||
export async function createStory(data: { title: string; description?: string; userId?: string }): Promise<Story> {
|
||||
export async function createStory(data: { title: string; description?: string; userId: string }): Promise<Story> {
|
||||
// Generate a unique slug
|
||||
let slug = generateComicSlug();
|
||||
let attempts = 0;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ export const stories = pgTable('stories', {
|
||||
title: text('title').notNull(),
|
||||
slug: text('slug').notNull().unique(),
|
||||
description: text('description'),
|
||||
userId: uuid('user_id'), // Optional - for future Clerk auth
|
||||
userId: uuid('user_id').notNull(), // Required Clerk user ID
|
||||
createdAt: timestamp('created_at').defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user