Skip to content

Debugging Google OAuthentication and Adding connection to supabase - #69

Open
MayankRai89 wants to merge 21 commits into
arpit2006:mainfrom
MayankRai89:main
Open

Debugging Google OAuthentication and Adding connection to supabase#69
MayankRai89 wants to merge 21 commits into
arpit2006:mainfrom
MayankRai89:main

Conversation

@MayankRai89

@MayankRai89 MayankRai89 commented Aug 29, 2026

Copy link
Copy Markdown

Description

This pull request improves user authentication reliability, integrates the official Google Identity Services (GIS) SDK on login/registration pages, resolves a token verification mismatch in the authentication controller, and establishes immediate database connection logging on application startup.

Key Changes:

  1. Google Identity Services Integration:

    • Integrated the official Google Sign-In SDK (https://accounts.google.com/gsi/client) into views/login.ejs and views/register.ejs.
    • Added automatic credential callback handling (handleGoogleCredentialResponse) to submit genuine ID tokens to /auth/google.
    • Retained developer prompt fallback for environments where client IDs or origins are not yet configured.
  2. OAuth Token Verification Fix:

    • Updated controllers/authController.js with smart token inspection (token.split('.').length === 3) to verify genuine Google JWTs with OAuth2Client.verifyIdToken() while safely decoding mock/development payloads without throwing Wrong number of segments in token errors.
    • Enforced session persistence via req.session.save() before performing redirect responses.
  3. Startup Database Connection:

    • Updated app.js to initialize and synchronize the Sequelize connection (Supabase / SQLite) immediately on server boot outside serverless environments, providing immediate feedback in console logs.

Related Issue

  • Fixes Google authentication failure when clicking "Continue with Google"
  • Resolves lazy database connection confusion on server startup

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Design/CSS styling changes
  • Documentation update (README, CONTRIBUTING, etc.)

How Has This Been Tested?

  1. Automated Unit & Integration Tests:
    • Ran npm test across the full test suite (test/**/*.test.js) — 43 / 43 tests passing (100%).
  2. Supabase PostgreSQL Verification:
    • Verified live connection, schema synchronization, and user lookup in production mode against remote Supabase database.
  3. Manual Flow Testing:
    • Tested /auth/google with both Google JWT and developer mock payloads, verifying successful user creation/login and redirect to /dashboard / /profile/setup.

Checklist:

  • My code follows the coding guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings or console errors.

…acking, streak management, and calendar export functionality
… navigation, modals, and tab switching functionality
…heduling, completion tracking, and calendar integration
…are, friend management controllers, and dashboard views with testing support.
…on, OAuth support, and database initialization on startup
@MayankRai89
MayankRai89 requested a review from arpit2006 as a code owner August 29, 2026 04:50
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@MayankRai89 is attempting to deploy a commit to the arpit2006's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 Thank you @MayankRai89 for submitting a Pull Request!

We're excited to review your contribution.

Before Review

✅ Ensure all CI checks pass
✅ Complete the PR template
✅ Link the related issue

📖 Before your PR is reviewed, check the PR Checklist in our Contributing Guide.

Happy Contributing! 🚀

@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

📏 Pull Request Size Report

🔴 Classification: Huge

Metric Value
Files Changed 72
Lines Added +5816
Lines Deleted -63
Total Changes 5879

Size Meter

██████████

Recommendation

🚨 This PR is very large. Splitting it into multiple PRs is strongly recommended.


Generated automatically by PR Size Analyzer.

@github-actions github-actions Bot added database dependencies Pull requests that update a dependency file environment security-review labels Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Welcome Back!

Hi @MayankRai89,

Thanks for contributing to CampusCompass again!

We appreciate your continued support ❤️


🗄 Database Changes

Please Verify

  • Migration tested
  • Existing data remains compatible
  • Rollback possible
  • Queries updated

🌟 General Tips

  • Keep commits focused
  • Respond to review comments
  • Ask questions if you're unsure
  • Make sure CI passes before requesting review

Happy Coding! 🚀


Generated automatically by Contributor Learning Assistant.

@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

📋 Pull Request Preview

📊 Summary

Metric Value
📄 Files Changed 72
➕ Additions +5816
➖ Deletions -63
🔄 Total Changes 5879
📦 PR Size 🔴 Very Large

📂 File Breakdown

Category Files
🎨 Frontend 0
⚙️ Backend 0
🧪 Tests 4
📚 Documentation 40
🤖 GitHub Actions 0
📦 Other 28

⏱️ Estimated Review Time

147 minute(s)


✅ Reviewer Checklist

  • Linked issue
  • Code follows project guidelines
  • Tests added/updated (if required)
  • Documentation updated (if required)
  • CI passes

⚠️ Large Pull Request

This PR contains 5879 changed lines.

Consider splitting it into smaller pull requests for easier review.


🤖 Generated automatically by the PR Preview Bot

@github-actions

Copy link
Copy Markdown
Contributor

🛡️ Critical File Change Detector

This Pull Request modifies important project files.

Changed Files

• .agents/skills/supabase-postgres-best-practices/references/security-privileges.md (Security)
• .agents/skills/supabase-postgres-best-practices/references/security-rls-basics.md (Security)
• .agents/skills/supabase-postgres-best-practices/references/security-rls-performance.md (Security)
• .env.example (Environment)
• controllers/authController.js (Security)
• package-lock.json (Dependencies)
• package.json (Dependencies)
• routes/auth.js (Security)
• services/securityMiddleware.js (Security)
• test/google-auth.test.js (Security)

Labels Added

🏷️ security-review
🏷️ environment
🏷️ dependencies

Reviewer Checklist

  • Verify dependency updates
  • Review CI/CD workflow changes
  • Check build configuration
  • Verify Docker changes
  • Check for security implications
  • Ensure backward compatibility

Generated automatically by Critical File Change Detector.

@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

⚠️ Suspicious Generated Code Detected

This PR contains patterns commonly associated with low-quality AI-generated submissions.

🔍 Detected Signals

  • Excessive comments in .agents/skills/supabase-postgres-best-practices/CHANGELOG.md
  • Generated-style separators in .agents/skills/supabase-postgres-best-practices/SKILL.md
  • Large insertion in .agents/skills/supabase-postgres-best-practices/references/_contributing.md (+170)
  • Excessive comments in .agents/skills/supabase-postgres-best-practices/references/_contributing.md
  • Generated-style separators in .agents/skills/supabase-postgres-best-practices/references/_contributing.md
  • Excessive comments in .agents/skills/supabase-postgres-best-practices/references/_sections.md
  • Excessive comments in .agents/skills/supabase-postgres-best-practices/references/conn-pooling.md
  • Excessive comments in .agents/skills/supabase-postgres-best-practices/references/data-n-plus-one.md
  • Excessive comments in .agents/skills/supabase-postgres-best-practices/references/data-pagination.md
  • Many helper functions added in .agents/skills/supabase-postgres-best-practices/references/security-rls-performance.md
  • Excessive comments in .agents/skills/supabase/CHANGELOG.md
  • Large insertion in .agents/skills/supabase/SKILL.md (+149)
  • Excessive comments in .agents/skills/supabase/SKILL.md
  • Many helper functions added in .agents/skills/supabase/SKILL.md
  • Excessive comments in .agents/skills/supabase/assets/feedback-issue-template.md
  • Excessive comments in .agents/skills/supabase/references/skill-feedback.md
  • Excessive comments in app.js
  • Excessive comments in controllers/authController.js
  • Large insertion in controllers/socialController.js (+317)
  • Excessive comments in controllers/socialController.js
  • Large insertion in controllers/studySprintController.js (+223)
  • Large insertion in package-lock.json (+521)
  • Excessive comments in package-lock.json
  • Large insertion in public/js/main.js (+213)
  • Excessive comments in public/js/main.js
  • Many helper functions added in public/js/main.js
  • Excessive comments in services/securityMiddleware.js
  • Large insertion in services/studySprintService.js (+367)
  • Excessive comments in services/studySprintService.js
  • Many helper functions added in services/studySprintService.js
  • Large insertion in test/google-auth.test.js (+148)
  • Large insertion in test/studySprint.test.js (+144)
  • Large insertion in views/social.ejs (+267)
  • Many helper functions added in views/social.ejs
  • Large insertion in views/studysprint.ejs (+627)

This PR has been flagged for manual review.

This is not an automatic rejection. A maintainer will review the changes before making a decision.


🤖 Generated automatically by PR Quality Guard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant