fix: remove hardcoded super admin credentials#90
Merged
devpathindcommunity-india merged 1 commit intoMay 19, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Removes hardcoded super admin email/password from the client bundle and seed/maintenance scripts, replacing them with environment variables, and changes the /ap super admin login flow to require an already-authenticated session rather than performing a silent sign-in with the embedded password. Addresses the critical credential-leak vulnerability described in issue #88.
Changes:
- Replace hardcoded
SUPER_ADMIN_EMAIL/SUPER_ADMIN_PASSWORDconstants withprocess.env.*lookups in the admin dashboard, the/appage, and seven scripts. - Reshape
/ap/page.tsxlogin: drop the auto sign-in with embedded password, show a "Restricted Access" screen when the visitor is not logged in, and require the current session's email to match the super admin email.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/admin/AdminDashboard.tsx | Replaces hardcoded email constant with env var, but leaves a stray SUPER_ADMIN_PASSWORD reference at line 1027. |
| src/app/ap/page.tsx | Reads super admin email from env; refuses access if user is not authenticated as that account instead of auto-signing in. |
| scripts/seed-admins.ts | Pulls super admin creds from env vars for the script's initial login. |
| scripts/recalculate-all-points.ts | Same env-var swap for credentials used by the recalc script. |
| scripts/full-recalc.ts | Same env-var swap for credentials. |
| scripts/create-super-admin.ts | Same env-var swap for credentials. |
| scripts/create-super-admin.js | Same env-var swap for credentials (JS variant). |
| scripts/create-super-admin-simple.js | Same env-var swap for credentials (simple JS variant). |
| scripts/create-super-admin-auth.ts | Same env-var swap for createUserWithEmailAndPassword call. |
Comments suppressed due to low confidence (1)
src/components/admin/AdminDashboard.tsx:23
process.env.NEXT_PUBLIC_SUPER_ADMIN_EMAILis typed asstring | undefined. Passing it tosignInWithEmailAndPassword(line 1027) is a type error, and if the env variable is not set, every comparison likeuser.email === SUPER_ADMIN_EMAILwill succeed for users whose email is alsoundefinedand otherwise silently mis-gate the UI. Consider asserting/validating the value at module load (throwing if missing) and narrowing the type tostring.
const SUPER_ADMIN_EMAIL = process.env.NEXT_PUBLIC_SUPER_ADMIN_EMAIL;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
devpathindcommunity-india
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes critical security vulnerability #88 by removing hardcoded credentials from frontend and scripts. Enforces proper auth flow for super admin page.