Skip to content

Fix Codex Auth Bug#58

Merged
victorSauceda merged 7 commits intomainfrom
fix/auth
Nov 4, 2025
Merged

Fix Codex Auth Bug#58
victorSauceda merged 7 commits intomainfrom
fix/auth

Conversation

@pstaylor-patrick
Copy link
Collaborator

@pstaylor-patrick pstaylor-patrick commented Nov 4, 2025

🚧 This PR is Part of a Series

👋 TL;DR

Adds database migration infrastructure, enhances authentication flow with admin email verification, and establishes ESLint configuration for code quality.

🔎 Details

This PR introduces database migration infrastructure using node-pg-migrate with npm scripts for migration operations. Authentication improvements include extracting user info fetching to a dedicated function and adding admin email verification with enhanced error handling. Database schema updates make existing migrations idempotent and add a mentioned_entries column. ESLint configuration has been established using Next.js presets to enforce code quality standards.

✅ How to Test

  1. Run database migrations using the new npm scripts to verify infrastructure works correctly
  2. Test authentication flow including callback endpoint and admin email verification
  3. Verify ESLint runs without errors and enforces code standards
  4. Confirm database schema changes apply safely (migrations are idempotent)
  5. Validate admin panel authentication with proper error handling for unauthorized users

🥜 GIF

lack-of-hustle

@netlify
Copy link

netlify bot commented Nov 4, 2025

Deploy Preview for f3-the-codex-demo failed. Why did it fail? →

Name Link
🔨 Latest commit 9420479
🔍 Latest deploy log https://app.netlify.com/projects/f3-the-codex-demo/deploys/690a5b3bf209b400085fdc46

Add ESLint with Next.js configuration to enforce code quality standards and maintain consistent coding practices across the project. The setup includes:

- ESLint 9.39.1 and eslint-config-next 16.0.1 dependencies
- ESLint configuration file (.eslintrc.json) extending Next.js core web vitals and TypeScript rules
- All necessary ESLint-related dependencies and plugins

This helps catch potential errors early and ensures code follows established patterns.
Move user info API call from callback page to auth library to:
- Centralize authentication logic
- Improve error handling with detailed messages
- Add proper caching headers
- Enable reuse across application
- Handle CORS issues by running server-side
Add database migration infrastructure using node-pg-migrate:

- Add npm scripts for migration operations (generate, up, down, redo)
- Create db-generate-migration.ts script to generate new migration files
- Create db-migrate.ts script to handle migration execution with various commands
- Add peer dependency flag to package-lock.json for node-pg-migrate compatibility

The migration scripts provide a consistent interface for database schema changes and support common migration operations including rollback capabilities.
- Add IF NOT EXISTS and IF EXISTS clauses to table/index creation/drop operations in existing migrations
- Add new migration to create mentioned_entries column in entries table
- Improve migration safety by making operations idempotent
- Ensure consistent formatting across migration files

These changes make migrations safer to run multiple times and add support for tracking mentioned entries relationships.
Add ESLint configuration file using the official Next.js ESLint config preset. This establishes code quality standards and linting rules for the project to maintain consistent code style and catch potential issues early in development.
- Add verifyAdminEmail action to check if user has admin access
- Wrap handleLogout in useCallback to prevent unnecessary re-renders
- Enhance authentication initialization with email verification
- Clear auth data and show appropriate error messages for unauthorized users
- Add proper error handling for authentication failures
- Update dependencies in useEffect to include handleLogout and verifyAdminEmail
@victorSauceda victorSauceda merged commit 4ce80c7 into main Nov 4, 2025
0 of 4 checks passed
@victorSauceda victorSauceda deleted the fix/auth branch November 4, 2025 20:26
This was referenced Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants