40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import { redis } from '@/lib/redis'
|
|
import { isAdmin } from '@/lib/auth/admin'
|
|
|
|
export async function POST(req: NextRequest, { params }: { params: { fid: string } }) {
|
|
try {
|
|
const adminFid = req.headers.get('x-farcaster-fid')
|
|
if (!adminFid || !isAdmin(adminFid)) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
}
|
|
|
|
const { fid } = params
|
|
|
|
await redis.sadd('banned:users', fid)
|
|
|
|
return NextResponse.json({ success: true })
|
|
} catch (error) {
|
|
console.error('Ban user error:', error)
|
|
return NextResponse.json({ error: 'Failed to ban user' }, { status: 500 })
|
|
}
|
|
}
|
|
|
|
export async function DELETE(req: NextRequest, { params }: { params: { fid: string } }) {
|
|
try {
|
|
const adminFid = req.headers.get('x-farcaster-fid')
|
|
if (!adminFid || !isAdmin(adminFid)) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
}
|
|
|
|
const { fid } = params
|
|
|
|
await redis.srem('banned:users', fid)
|
|
|
|
return NextResponse.json({ success: true })
|
|
} catch (error) {
|
|
console.error('Unban user error:', error)
|
|
return NextResponse.json({ error: 'Failed to unban user' }, { status: 500 })
|
|
}
|
|
}
|