Skip to content

Commit 52abaa4

Browse files
committed
chore: change variable name
1 parent e92dea5 commit 52abaa4

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/graphql/post.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -743,16 +743,16 @@ export const resolvers: IResolvers<any, ApolloContext> = {
743743
}
744744

745745
// check bot
746-
if (!data.is_private || !data.is_temp) {
747-
const isTrustUser = await userService.checkTrust(ctx.user_id);
748-
if (!isTrustUser && !data.token) {
749-
throw new ApolloError(
750-
'A Turnstile token is required for users who are not trusted',
751-
'NO_PERMISSION'
752-
);
753-
}
746+
if (!data.is_private && !data.is_temp) {
747+
const isTrustedUser = await userService.checkTrust(ctx.user_id);
748+
if (!isTrustedUser) {
749+
if (!data.token) {
750+
throw new ApolloError(
751+
'A Turnstile token is required for users who are not trusted',
752+
'NO_PERMISSION'
753+
);
754+
}
754755

755-
if (!isTrustUser) {
756756
const isVerified = await verifyTurnstileToken(data.token!);
757757
if (!isVerified) {
758758
post.is_private = true;
@@ -1054,16 +1054,16 @@ export const resolvers: IResolvers<any, ApolloContext> = {
10541054
}
10551055

10561056
// check bot
1057-
if (!is_private || !is_temp) {
1058-
const isTrustUser = await userService.checkTrust(ctx.user_id);
1059-
if (!isTrustUser && !token) {
1060-
throw new ApolloError(
1061-
'A Turnstile token is required for users who are not trusted',
1062-
'NO_PERMISSION'
1063-
);
1064-
}
1057+
if (!is_private && !is_temp) {
1058+
const isTrustedUser = await userService.checkTrust(ctx.user_id);
1059+
if (!isTrustedUser) {
1060+
if (!token) {
1061+
throw new ApolloError(
1062+
'A Turnstile token is required for users who are not trusted',
1063+
'NO_PERMISSION'
1064+
);
1065+
}
10651066

1066-
if (!isTrustUser) {
10671067
const isVerified = await verifyTurnstileToken(token!);
10681068
if (!isVerified) {
10691069
post.is_private = true;

src/lib/turnstile.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import axios from 'axios';
22

33
const TURNSTILE_SECRET_KEY = process.env.TURNSTILE_SECRET_KEY;
44

5-
console.log('verifyTurnstileToken', TURNSTILE_SECRET_KEY);
65
const VERIFY_URL = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
76

87
export async function verifyTurnstileToken(token: string): Promise<boolean> {
@@ -12,7 +11,6 @@ export async function verifyTurnstileToken(token: string): Promise<boolean> {
1211
response: token,
1312
});
1413

15-
console.log('toklen', res);
1614
return res.data.success;
1715
} catch (error) {
1816
console.log('verifyTurnstileToken error', error);

0 commit comments

Comments
 (0)