From c22945cd4eb2337984070162676ee74f21a8dba7 Mon Sep 17 00:00:00 2001 From: Ned Date: Wed, 27 May 2026 16:39:47 +0000 Subject: [PATCH] fix: remove broken OAuth login, scrub hardcoded project ID --- .env.example | 8 ++------ src/App.tsx | 34 ++-------------------------------- src/lib/appwrite.ts | 23 +++-------------------- 3 files changed, 7 insertions(+), 58 deletions(-) diff --git a/.env.example b/.env.example index a9fa015..7a09b2f 100644 --- a/.env.example +++ b/.env.example @@ -1,12 +1,8 @@ VITE_APPWRITE_ENDPOINT=https://fra.cloud.appwrite.io/v1 -VITE_APPWRITE_PROJECT_ID=6a0752ee001fb2ef7138 +VITE_APPWRITE_PROJECT_ID=your-project-id VITE_APPWRITE_DATABASE_ID=redbull_tracker VITE_APPWRITE_COLLECTION_ID=intake_entries VITE_APPWRITE_BARCODE_COLLECTION_ID=barcode_products -# Optional. Leave blank in local dev so the app uses the current Vite origin. -VITE_APPWRITE_OAUTH_SUCCESS_URL= -VITE_APPWRITE_OAUTH_FAILURE_URL= - # Server/admin only. Never prefix with VITE_. Needed only for npm run setup:appwrite. -APPWRITE_API_KEY= +APPWRITE_API_KEY= \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 606ae58..b28ebd3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -13,7 +13,6 @@ import { FileJson, FileSpreadsheet, Gauge, - Github, Home, LineChart, Loader2, @@ -75,7 +74,7 @@ import { type AppTheme, } from "./data/themes"; import { themeTokensToStyle } from "./lib/themeTokens"; -import { account, appwriteConfig, Channel, client, OAuthProvider, pingAppwrite } from "./lib/appwrite"; +import { account, appwriteConfig, Channel, client, pingAppwrite } from "./lib/appwrite"; import { appwriteErrorMessage, createEntries, @@ -343,16 +342,6 @@ function App() { } } - function startOAuth(provider: "github" | "google") { - const selectedProvider = provider === "github" ? OAuthProvider.Github : OAuthProvider.Google; - setBusyAction("oauth"); - account.createOAuth2Session({ - provider: selectedProvider, - success: appwriteConfig.oauthSuccessUrl, - failure: appwriteConfig.oauthFailureUrl, - }); - } - async function logout() { setBusyAction("logout"); setSyncError(""); @@ -633,12 +622,11 @@ function App() { return ( ); @@ -891,7 +879,6 @@ function AuthView({ shellStyle, themeId, onLogin, - onOAuth, onSignup, }: { authError: string; @@ -900,7 +887,6 @@ function AuthView({ shellStyle: CSSProperties; themeId: string; onLogin: (email: string, password: string) => Promise; - onOAuth: (provider: "github" | "google") => void; onSignup: (name: string, email: string, password: string) => Promise; }) { const [mode, setMode] = useState("login"); @@ -971,22 +957,6 @@ function AuthView({ -
- - or - -
- -
- - -
diff --git a/src/lib/appwrite.ts b/src/lib/appwrite.ts index d015ea9..02e579c 100644 --- a/src/lib/appwrite.ts +++ b/src/lib/appwrite.ts @@ -1,16 +1,13 @@ -import { Account, Channel, Client, ID, OAuthProvider, Permission, Query, Role, TablesDB } from "appwrite"; +import { Account, Channel, Client, ID, Permission, Query, Role, TablesDB } from "appwrite"; const env = import.meta.env; -const currentOrigin = window.location.origin; export const appwriteConfig = { endpoint: env.VITE_APPWRITE_ENDPOINT || "https://fra.cloud.appwrite.io/v1", - projectId: env.VITE_APPWRITE_PROJECT_ID || "6a0752ee001fb2ef7138", + projectId: env.VITE_APPWRITE_PROJECT_ID!, databaseId: env.VITE_APPWRITE_DATABASE_ID || "redbull_tracker", collectionId: env.VITE_APPWRITE_COLLECTION_ID || "intake_entries", barcodeCollectionId: env.VITE_APPWRITE_BARCODE_COLLECTION_ID || "barcode_products", - oauthSuccessUrl: resolveOAuthUrl(env.VITE_APPWRITE_OAUTH_SUCCESS_URL), - oauthFailureUrl: resolveOAuthUrl(env.VITE_APPWRITE_OAUTH_FAILURE_URL), }; const client = new Client() @@ -24,18 +21,4 @@ export async function pingAppwrite() { return client.ping(); } -export { account, Channel, client, ID, OAuthProvider, Permission, Query, Role, tablesDB }; - -function resolveOAuthUrl(value?: string) { - if (!value) return currentOrigin; - - const configured = new URL(value, currentOrigin); - const current = new URL(currentOrigin); - const localHosts = new Set(["localhost", "127.0.0.1", "::1"]); - - if (env.DEV && localHosts.has(configured.hostname) && localHosts.has(current.hostname)) { - return currentOrigin; - } - - return configured.toString().replace(/\/$/, ""); -} +export { account, Channel, client, ID, Permission, Query, Role, tablesDB };