Remove temporary bootstrap endpoint
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Elysia, t } from 'elysia';
|
||||
import { db } from '../db';
|
||||
import { tasks, projects, hammerWebhooks, users, activityLog, accounts, sessions } from '../db/schema';
|
||||
import { tasks, projects, hammerWebhooks, users, activityLog } from '../db/schema';
|
||||
import { eq, and, asc, desc, sql } from 'drizzle-orm';
|
||||
import crypto from 'crypto';
|
||||
import { auth } from '../lib/auth';
|
||||
@@ -416,41 +416,4 @@ export const hammerRoutes = new Elysia({ prefix: '/hammer' })
|
||||
}),
|
||||
})
|
||||
|
||||
// Bootstrap: delete and recreate user with proper BetterAuth password (temporary - REMOVE after use)
|
||||
.post('/bootstrap-recreate', async ({ body, set }) => {
|
||||
const { email, password, name } = body;
|
||||
const existing = await db.query.users.findFirst({
|
||||
where: eq(users.email, email),
|
||||
});
|
||||
if (existing) {
|
||||
try {
|
||||
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));
|
||||
} catch(e) { console.error('sessions delete:', e); }
|
||||
try {
|
||||
await db.delete(users).where(eq(users.id, existing.id));
|
||||
} catch(e) { console.error('users delete:', e); }
|
||||
}
|
||||
const result = await auth.api.signUpEmail({
|
||||
body: { email, password, name },
|
||||
});
|
||||
if (!result) {
|
||||
set.status = 500;
|
||||
throw new Error('Failed to create user');
|
||||
}
|
||||
const newUser = await db.query.users.findFirst({
|
||||
where: eq(users.email, email),
|
||||
});
|
||||
if (newUser) {
|
||||
await db.update(users).set({ role: 'admin' }).where(eq(users.id, newUser.id));
|
||||
}
|
||||
return { success: true, email, role: 'admin' };
|
||||
}, {
|
||||
body: t.Object({
|
||||
email: t.String({ format: 'email' }),
|
||||
password: t.String({ minLength: 8 }),
|
||||
name: t.String(),
|
||||
}),
|
||||
});
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user