feat: admin can answer questions without paying for testing
- Server: /api/respuesta/enviar checks admin cookie; if authorized, bypasses credit check and stores answer via insertAdminAnswer() - DB: insertAdminAnswer() inserts directly into user_answers with username='Admin', skipping the credit budget entirely - Frontend: ProposeAnswer checks /api/admin/status on mount; if admin is logged in, shows the answer form directly (orange Admin badge) instead of the payment tier selection Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
7
db.ts
7
db.ts
@@ -189,6 +189,13 @@ export function getCreditByOrder(orderId: string): {
|
||||
} | null;
|
||||
}
|
||||
|
||||
/** Insert a user answer directly, bypassing credit checks (admin use). */
|
||||
export function insertAdminAnswer(roundNum: number, text: string, username: string): void {
|
||||
db.prepare(
|
||||
"INSERT INTO user_answers (round_num, text, username, token) VALUES ($roundNum, $text, $username, 'admin')"
|
||||
).run({ $roundNum: roundNum, $text: text, $username: username });
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically validates a credit token, records a user answer for the given
|
||||
* round, and decrements the answer budget. Returns null if the token is
|
||||
|
||||
Reference in New Issue
Block a user