Full rental marketplace with 6 categories (apartment, house, car, motorcycle, bicycle, ebike). Booking workflow: create → confirm → pay → active → complete → payout. Landlord dashboard, admin moderation, availability calendar, Stripe Connect payouts. 14 QA bugs found and fixed including validator schemas, API response types, HTTP methods. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
626 B
TypeScript
25 lines
626 B
TypeScript
import type { Request, Response, NextFunction } from 'express';
|
|
import { prisma } from '../config/database.js';
|
|
|
|
export async function checkBanned(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
if (!req.userId) {
|
|
next();
|
|
return;
|
|
}
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { id: req.userId },
|
|
select: { isBanned: true, banReason: true },
|
|
});
|
|
|
|
if (user?.isBanned) {
|
|
res.status(403).json({
|
|
message: 'Account suspended',
|
|
reason: user.banReason || 'Your account has been suspended. Contact support for more information.',
|
|
});
|
|
return;
|
|
}
|
|
|
|
next();
|
|
}
|