feat: user management — detail view, block/unblock, plan change
routes/admin.js: GET /users/:id (profile+channels+balance+transactions) PATCH /users/:id (is_blocked, plan_code, name) plan change: cancels active sub → creates new → credits reset generate.js: check is_blocked before generation → 403 ACCOUNT_BLOCKED DB: users.is_blocked BOOLEAN DEFAULT false
This commit is contained in:
@@ -19,6 +19,12 @@ router.post('/', async (req, res) => {
|
||||
if (type !== 'topics' && !topic) return res.status(400).json({ error: 'topic is required' });
|
||||
if (type === 'post' && !channelId) return res.status(400).json({ error: 'channelId is required for posts' });
|
||||
|
||||
// Проверяем не заблокирован ли пользователь
|
||||
if (userId) {
|
||||
const { rows: [u] } = await require('../config/db').query('SELECT is_blocked FROM users WHERE id=$1', [userId]);
|
||||
if (u?.is_blocked) return res.status(403).json({ error: 'Аккаунт заблокирован', code: 'ACCOUNT_BLOCKED' });
|
||||
}
|
||||
|
||||
// Проверка и списание кредитов
|
||||
const billingOp = BILLING_OP[type];
|
||||
let billingResult = null;
|
||||
|
||||
Reference in New Issue
Block a user