fix: remove broken OAuth login, scrub hardcoded project ID

This commit is contained in:
Ned
2026-05-27 16:39:47 +00:00
parent 23801f79d4
commit c22945cd4e
3 changed files with 7 additions and 58 deletions
+1 -5
View File
@@ -1,12 +1,8 @@
VITE_APPWRITE_ENDPOINT=https://fra.cloud.appwrite.io/v1 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_DATABASE_ID=redbull_tracker
VITE_APPWRITE_COLLECTION_ID=intake_entries VITE_APPWRITE_COLLECTION_ID=intake_entries
VITE_APPWRITE_BARCODE_COLLECTION_ID=barcode_products 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. # Server/admin only. Never prefix with VITE_. Needed only for npm run setup:appwrite.
APPWRITE_API_KEY= APPWRITE_API_KEY=
+2 -32
View File
@@ -13,7 +13,6 @@ import {
FileJson, FileJson,
FileSpreadsheet, FileSpreadsheet,
Gauge, Gauge,
Github,
Home, Home,
LineChart, LineChart,
Loader2, Loader2,
@@ -75,7 +74,7 @@ import {
type AppTheme, type AppTheme,
} from "./data/themes"; } from "./data/themes";
import { themeTokensToStyle } from "./lib/themeTokens"; 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 { import {
appwriteErrorMessage, appwriteErrorMessage,
createEntries, 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() { async function logout() {
setBusyAction("logout"); setBusyAction("logout");
setSyncError(""); setSyncError("");
@@ -633,12 +622,11 @@ function App() {
return ( return (
<AuthView <AuthView
authError={authError} authError={authError}
busy={busyAction === "auth" || busyAction === "oauth"} busy={busyAction === "auth"}
setupStatus={setupStatus} setupStatus={setupStatus}
shellStyle={shellStyle} shellStyle={shellStyle}
themeId={themeId} themeId={themeId}
onLogin={login} onLogin={login}
onOAuth={startOAuth}
onSignup={signup} onSignup={signup}
/> />
); );
@@ -891,7 +879,6 @@ function AuthView({
shellStyle, shellStyle,
themeId, themeId,
onLogin, onLogin,
onOAuth,
onSignup, onSignup,
}: { }: {
authError: string; authError: string;
@@ -900,7 +887,6 @@ function AuthView({
shellStyle: CSSProperties; shellStyle: CSSProperties;
themeId: string; themeId: string;
onLogin: (email: string, password: string) => Promise<void>; onLogin: (email: string, password: string) => Promise<void>;
onOAuth: (provider: "github" | "google") => void;
onSignup: (name: string, email: string, password: string) => Promise<void>; onSignup: (name: string, email: string, password: string) => Promise<void>;
}) { }) {
const [mode, setMode] = useState<AuthMode>("login"); const [mode, setMode] = useState<AuthMode>("login");
@@ -971,22 +957,6 @@ function AuthView({
</button> </button>
</form> </form>
<div className="my-5 grid grid-cols-[1fr_auto_1fr] items-center gap-3 text-xs uppercase tracking-[0.22em]" style={{ color: "#80868b" }}>
<span className="h-px" style={{ background: "#d8e1ee" }} />
or
<span className="h-px" style={{ background: "#d8e1ee" }} />
</div>
<div className="grid gap-2">
<button className="secondary-button justify-center" type="button" disabled={busy} onClick={() => onOAuth("github")}>
<Github size={17} aria-hidden="true" />
Continue with GitHub
</button>
<button className="secondary-button justify-center" type="button" disabled={busy} onClick={() => onOAuth("google")}>
<User size={17} aria-hidden="true" />
Continue with Google
</button>
</div>
</div> </div>
<div className="grid gap-2 sm:grid-cols-2"> <div className="grid gap-2 sm:grid-cols-2">
+3 -20
View File
@@ -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 env = import.meta.env;
const currentOrigin = window.location.origin;
export const appwriteConfig = { export const appwriteConfig = {
endpoint: env.VITE_APPWRITE_ENDPOINT || "https://fra.cloud.appwrite.io/v1", 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", databaseId: env.VITE_APPWRITE_DATABASE_ID || "redbull_tracker",
collectionId: env.VITE_APPWRITE_COLLECTION_ID || "intake_entries", collectionId: env.VITE_APPWRITE_COLLECTION_ID || "intake_entries",
barcodeCollectionId: env.VITE_APPWRITE_BARCODE_COLLECTION_ID || "barcode_products", 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() const client = new Client()
@@ -24,18 +21,4 @@ export async function pingAppwrite() {
return client.ping(); 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(/\/$/, "");
}