Admin zone creation for a member (Marty 2026-11-14, approved named admin actions instead of signing in as a member): POST /api/admin/zones {owner, name, size, site, reason}, existing accounts only, same zones.create rules, logged. qa member 57/57
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2830,6 +2830,16 @@ const server = http.createServer(async (req, res) => {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const r = await zones.create(s.email, await readBody(req)); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
// admin: create a zone in a member's account (Marty 2026-11-14, approved: named admin actions instead of signing in as a member).
|
||||
// {owner, name, size, site, reason}: the account must exist; same zones.create rules as the member's own button; logged.
|
||||
if (p === '/api/admin/zones' && req.method === 'POST') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const b = await readBody(req); const owner = String(b.owner || '').trim().toLowerCase();
|
||||
if (!owner || !(await accounts.byEmail(owner))) return json(res, 400, { error: 'No such account.' });
|
||||
const r = await zones.create(owner, b);
|
||||
console.log('admin zone', r.zone ? r.zone.id : 'refused', 'for', owner.replace(/^(..).*(@.*)$/, '$1***$2'), 'reason:', String(b.reason || '').slice(0, 120));
|
||||
return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
m = /^\/api\/my\/zones\/(ls-[a-f0-9]{6})$/.exec(p);
|
||||
if (m && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
|
||||
Reference in New Issue
Block a user