From 5cbe8f0b1316489e45f5e831eec13a6d46b366bf Mon Sep 17 00:00:00 2001 From: Ned Date: Wed, 27 May 2026 13:42:21 +0000 Subject: [PATCH] fix: remove broken OAuth login, scrub hardcoded project ID, prep for public release --- .env.example | 4 ---- README.md | 5 ++--- src/App.tsx | 37 +++++-------------------------------- src/lib/appwrite.ts | 21 ++++----------------- 4 files changed, 11 insertions(+), 56 deletions(-) diff --git a/.env.example b/.env.example index ae966fe..4a14ee9 100644 --- a/.env.example +++ b/.env.example @@ -4,10 +4,6 @@ VITE_APPWRITE_DATABASE_ID=redbull_tracker VITE_APPWRITE_COLLECTION_ID=intake_entries VITE_APPWRITE_CHAT_COLLECTION_ID=coach_chats -# Optional. Leave blank in local dev so the app uses the current Vite origin, -# including fallback ports like http://127.0.0.1:5174. -VITE_APPWRITE_OAUTH_SUCCESS_URL= -VITE_APPWRITE_OAUTH_FAILURE_URL= # Server-only. Do not prefix with VITE_ or it will be exposed to the browser. OLLAMA_API_KEY= diff --git a/README.md b/README.md index 69d57e6..9dca596 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Track your Red Bull consumption with per-can logging, barcode scanning, spending - **Export** — download your data as Excel or JSON anytime - **Material You theming** — every flavour gets its own dynamic colour palette. Dark mode included - **Onboarding flow** — guided setup for new users with limit preferences -- **Appwrite auth** — email/password + OAuth login, row-level security per user +- **Appwrite auth** — email/password login, row-level security per user ## Tech Stack @@ -78,8 +78,7 @@ The app runs at `http://localhost:5173`. | `VITE_APPWRITE_DATABASE_ID` | Yes | Database ID (default: `redbull_tracker`) | | `VITE_APPWRITE_COLLECTION_ID` | Yes | Intake entries collection ID | | `VITE_APPWRITE_CHAT_COLLECTION_ID` | Yes | Coach chats collection ID | -| `VITE_APPWRITE_OAUTH_SUCCESS_URL` | No | OAuth redirect URL | -| `VITE_APPWRITE_OAUTH_FAILURE_URL` | No | OAuth failure redirect URL | + | `VITE_OLLAMA_PROXY_URL` | No | AI coach proxy endpoint | | `OLLAMA_API_KEY` | No | Server-side Ollama API key | | `OLLAMA_MODEL` | No | Ollama model for coach (default: `deepseek-v4-pro:cloud`) | diff --git a/src/App.tsx b/src/App.tsx index f7d9035..ea18706 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,7 +11,6 @@ import { FileJson, FileSpreadsheet, Gauge, - Github, Home, Info, LineChart, @@ -72,7 +71,7 @@ import { type ThemeCategory, } 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, @@ -366,18 +365,7 @@ function App() { } } - function startOAuth(provider: "github" | "google") { - const selectedProvider = provider === "github" ? OAuthProvider.Github : OAuthProvider.Google; - setActionLoading("oauth"); - account.createOAuth2Session({ - provider: selectedProvider, - success: appwriteConfig.oauthSuccessUrl, - failure: appwriteConfig.oauthFailureUrl, - }); - } - async function logout() { - setActionLoading("logout"); setDataError(""); try { await account.deleteSession({ sessionId: "current" }); @@ -653,12 +641,12 @@ function App() { return ( ); @@ -926,7 +914,7 @@ function AuthView({ shellStyle, themeId, onLogin, - onOAuth, + onSignup, }: { authError: string; @@ -935,7 +923,7 @@ 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"); @@ -1014,22 +1002,7 @@ function AuthView({ -
- - or - -
-
- - -
diff --git a/src/lib/appwrite.ts b/src/lib/appwrite.ts index f2e0a14..60afb8b 100644 --- a/src/lib/appwrite.ts +++ b/src/lib/appwrite.ts @@ -1,17 +1,16 @@ -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", chatCollectionId: env.VITE_APPWRITE_CHAT_COLLECTION_ID || "coach_chats", 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() @@ -25,18 +24,6 @@ export async function pingAppwrite() { return client.ping(); } -export { account, Channel, client, ID, OAuthProvider, Permission, Query, Role, tablesDB }; +export { account, Channel, client, ID, 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(/\/$/, ""); -}