Fix bootstrap-recreate: use static imports and error handling
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Elysia, t } from 'elysia';
|
import { Elysia, t } from 'elysia';
|
||||||
import { db } from '../db';
|
import { db } from '../db';
|
||||||
import { tasks, projects, hammerWebhooks, users, activityLog } from '../db/schema';
|
import { tasks, projects, hammerWebhooks, users, activityLog, accounts, sessions } from '../db/schema';
|
||||||
import { eq, and, asc, desc, sql } from 'drizzle-orm';
|
import { eq, and, asc, desc, sql } from 'drizzle-orm';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { auth } from '../lib/auth';
|
import { auth } from '../lib/auth';
|
||||||
@@ -423,10 +423,15 @@ export const hammerRoutes = new Elysia({ prefix: '/hammer' })
|
|||||||
where: eq(users.email, email),
|
where: eq(users.email, email),
|
||||||
});
|
});
|
||||||
if (existing) {
|
if (existing) {
|
||||||
const { accounts, sessions } = await import('../db/schema');
|
try {
|
||||||
await db.delete(accounts).where(eq(accounts.userId, existing.id));
|
await db.delete(accounts).where(eq(accounts.userId, existing.id));
|
||||||
|
} catch(e) { console.error('accounts delete:', e); }
|
||||||
|
try {
|
||||||
await db.delete(sessions).where(eq(sessions.userId, existing.id));
|
await db.delete(sessions).where(eq(sessions.userId, existing.id));
|
||||||
|
} catch(e) { console.error('sessions delete:', e); }
|
||||||
|
try {
|
||||||
await db.delete(users).where(eq(users.id, existing.id));
|
await db.delete(users).where(eq(users.id, existing.id));
|
||||||
|
} catch(e) { console.error('users delete:', e); }
|
||||||
}
|
}
|
||||||
const result = await auth.api.signUpEmail({
|
const result = await auth.api.signUpEmail({
|
||||||
body: { email, password, name },
|
body: { email, password, name },
|
||||||
|
|||||||
Reference in New Issue
Block a user