feat : remove admin bypass ads

This commit is contained in:
2026-09-27 15:11:37 +07:00 Unverified
parent 33ee40a0a8
commit d9dcf1a3f8
2 changed files with 4 additions and 16 deletions
+1 -13
View File
@@ -1,21 +1,9 @@
"use client";
import Script from "next/script";
import { authClient } from "@/lib/auth/client";
const clientId = process.env.NEXT_PUBLIC_GOOGLE_ADSENSE_CLIENT_ID?.trim();
export function GoogleAdsense() {
const { data: session, error, isPending } = authClient.useSession();
if (
process.env.NODE_ENV !== "production" ||
!clientId ||
isPending ||
error ||
session
) {
if (process.env.NODE_ENV !== "production" || !clientId) {
return null;
}
+3 -3
View File
@@ -59,7 +59,7 @@ describe("public rendering performance", () => {
});
});
it("loads AdSense only after confirming the visitor is signed out", async () => {
it("loads AdSense for every visitor, including signed-in admins", async () => {
const [adsense, home, guide, guideSection, adsTxt] = await Promise.all([
repositoryFile("components/public/google-adsense.tsx"),
repositoryFile("app/page.tsx"),
@@ -68,9 +68,9 @@ describe("public rendering performance", () => {
repositoryFile("public/ads.txt"),
]);
expect(adsense).toContain("authClient.useSession()");
expect(adsense).not.toContain("authClient.useSession()");
expect(adsense).not.toContain('from "@/lib/auth/client"');
expect(adsense).toContain('process.env.NODE_ENV !== "production"');
expect(adsense).toMatch(/isPending \|\|\s+error \|\|\s+session/u);
expect(adsense).toContain("pagead2.googlesyndication.com");
expect(home).toContain("<GoogleAdsense />");
expect(guide).toContain("<GoogleAdsense />");