revert captcha
This commit is contained in:
parent
519236913e
commit
96cb799cc7
12 changed files with 12 additions and 186 deletions
|
|
@ -12,6 +12,5 @@ export const load: LayoutServerLoad = async (event) => {
|
|||
return {
|
||||
userSession: event.locals.userSession,
|
||||
url: event.url.pathname,
|
||||
turnstileVerified: event.locals.turnstileVerified ?? false
|
||||
};
|
||||
};
|
||||
|
|
@ -5,8 +5,6 @@ import { coin, userPortfolio, user, transaction, priceHistory } from '$lib/serve
|
|||
import { eq, and, gte } from 'drizzle-orm';
|
||||
import { redis } from '$lib/server/redis';
|
||||
import { createNotification } from '$lib/server/notification';
|
||||
import { verifyTurnstile } from '$lib/server/turnstile';
|
||||
import { setTurnstileVerifiedRedis, isTurnstileVerifiedRedis } from '$lib/server/redis';
|
||||
|
||||
async function calculate24hMetrics(coinId: number, currentPrice: number) {
|
||||
const twentyFourHoursAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
|
||||
|
|
@ -55,16 +53,7 @@ export async function POST({ params, request }) {
|
|||
}
|
||||
|
||||
const { coinSymbol } = params;
|
||||
const { type, amount, turnstileToken } = await request.json();
|
||||
|
||||
const alreadyVerified = await isTurnstileVerifiedRedis(session.user.id);
|
||||
|
||||
if (!alreadyVerified) {
|
||||
if (!turnstileToken || !(await verifyTurnstile(turnstileToken, request))) {
|
||||
throw error(400, 'Captcha verification failed');
|
||||
}
|
||||
await setTurnstileVerifiedRedis(session.user.id);
|
||||
}
|
||||
const { type, amount } = await request.json();
|
||||
|
||||
if (!['BUY', 'SELL'].includes(type)) {
|
||||
throw error(400, 'Invalid transaction type');
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import { user, userPortfolio, coin, transaction } from '$lib/server/db/schema';
|
|||
import { eq, and } from 'drizzle-orm';
|
||||
import { createNotification } from '$lib/server/notification';
|
||||
import { formatValue } from '$lib/utils';
|
||||
import { verifyTurnstile } from '$lib/server/turnstile';
|
||||
import { setTurnstileVerifiedRedis, isTurnstileVerifiedRedis } from '$lib/server/redis';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
interface TransferRequest {
|
||||
|
|
@ -24,16 +22,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||
if (!session?.user) {
|
||||
throw error(401, 'Not authenticated');
|
||||
} try {
|
||||
const { recipientUsername, type, amount, coinSymbol, turnstileToken }: TransferRequest & { turnstileToken?: string } = await request.json();
|
||||
|
||||
const alreadyVerified = await isTurnstileVerifiedRedis(session.user.id);
|
||||
|
||||
if (!alreadyVerified) {
|
||||
if (!turnstileToken || !(await verifyTurnstile(turnstileToken, request))) {
|
||||
throw error(400, 'Captcha verification failed');
|
||||
}
|
||||
await setTurnstileVerifiedRedis(session.user.id);
|
||||
}
|
||||
const { recipientUsername, type, amount, coinSymbol }: TransferRequest = await request.json();
|
||||
|
||||
if (!recipientUsername || !type || !amount || typeof amount !== 'number' || !Number.isFinite(amount) || amount <= 0) {
|
||||
throw error(400, 'Invalid transfer parameters');
|
||||
|
|
|
|||
Reference in a new issue