(kiloUserId: string)
| 7 | import { getUserFromAuth } from '@/lib/user/server'; |
| 8 | import { captureException } from '@sentry/nextjs'; |
| 9 | |
| 10 | export async function nuke() { |
| 11 | if (!IS_DEVELOPMENT) { |
| 12 | throw new Error('Nuke is only available in development'); |
| 13 | } |
| 14 | |
| 15 | const { user, authFailedResponse } = await getUserFromAuth({ adminOnly: false }); |
| 16 | if (authFailedResponse || !user) { |
| 17 | throw new Error('Unauthorized'); |
| 18 | } |
| 19 | |
| 20 | try { |
| 21 | const current = await findUserById(user.id); |
| 22 | if (!current) { |
| 23 | throw new Error(`User not found: ${user.id}`); |
| 24 | } |
| 25 | |
| 26 | await softDeleteUser(user.id); |
| 27 | } catch (error) { |
| 28 | console.error('Error nuking account:', error); |
| 29 | captureException(error, { |
| 30 | tags: { source: 'dev_nuke_account' }, |
| 31 | extra: { kiloUserId: user.id }, |
| 32 | level: 'error', |
| 33 | }); |
no test coverage detected