fix: resolve interview scheduling and auth redirect by updating schem…#416
fix: resolve interview scheduling and auth redirect by updating schem…#416bhaikd wants to merge 4 commits into
Conversation
…a, controller, routes, and frontend navigation
|
@bhaikd is attempting to deploy a commit to the santanu-atta03's projects Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for creating a PR for your Issue!
|
There was a problem hiding this comment.
Pull request overview
This PR addresses an authentication/redirect loop occurring after interview setup by ensuring the frontend navigates using a valid interview identifier and by adding backend support for retrieving scheduled interview metadata/session data needed to load the interview room.
Changes:
- Fixed frontend navigation to route using
id/interviewIdreturned from the create-interview API instead of_id. - Expanded the Interview schema to support resume-based scheduling metadata (role/resume URL/text/scheduled time) and made some config fields optional.
- Enhanced backend interview creation to support a resume-upload flow (PDF parsing + Cloudinary upload) and added retrieval endpoints for interview details and session.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| Frontend/src/components/AiInterview/InterviewSetup.jsx | Navigates to the interview room using the returned interview identifier. |
| Backend/routes/interview.route.js | Registers new GET endpoints to retrieve interview details and session data. |
| Backend/models/Interview.model.js | Adds scheduling + resume fields and relaxes some config requirements. |
| Backend/controllers/Interview.controller.js | Implements dual create-interview flows (direct config vs resume upload) and adds retrieval handlers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| const interview = await createInterview(data, setLoading, token); | ||
| navigate(`/interview/${interview._id}`); | ||
| navigate(`/interview/${interview.id || interview.interviewId}`); | ||
| } catch (error) { |
| if (!finalDomain || !finalSubDomain || !finalInterviewType) { | ||
| return res.status(400).json({ | ||
| success: false, | ||
| message: "Please provide all required fields (domain, subDomain, interviewType)", | ||
| }); | ||
| } |
| try { | ||
| const uploadResult = await uploadToCloudinary(resumeFile, "resumes"); | ||
| resumeUrl = uploadResult.secure_url; | ||
| } catch (uploadError) { | ||
| console.error("Cloudinary upload error:", uploadError); | ||
| return res.status(500).json({ | ||
| success: false, | ||
| message: "Failed to upload resume to Cloudinary", | ||
| error: uploadError.message, | ||
| }); | ||
| } |
| const { interviewId } = req.params; | ||
| const userId = req.user.id; | ||
|
|
||
| const interview = await Interview.findOne({ _id: interviewId, userId }); | ||
|
|
| const { interviewId } = req.params; | ||
| const userId = req.user.id; | ||
|
|
||
| const session = await InterviewSession.findOne({ interviewId, userId }); | ||
|
|
| // Get single interview details | ||
| router.get("/:interviewId", interviewController.getInterviewById); | ||
|
|
||
| // Get interview session | ||
| router.get("/:interviewId/session", interviewController.getInterviewSession); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Pull Request — Intervyo
Thank you for contributing to **Intervyo, an AI-powered interview simulation platform!
Please fill out the following details to help us review your PR efficiently.
📌 Related Issue
Fixes # (mention issue number here)
Fixes Issue #413
Description of Changes
Describe your changes and their purpose.
Fixed a critical authentication redirect bug that occurred when scheduling and starting an interview. The issue was caused by a combination of payload/schema mismatch during resume uploads, missing backend retrieval endpoints, and incorrect client-side parameter naming.
Specifically:
Frontend Navigation Fix: Updated InterviewSetup.jsx to navigate using the returned interview ID or interviewID instead of the undefined _id property, preventing routing to /interview/undefined.
Database Schema Expansion: Added role, resumeUrl, resumeText, and scheduledAt fields to Interview.model.js and made the direct configuration properties (domain, subDomain, and interviewType) optional.
Backend Controller Enhancement: Updated createInterview in Interview.controller.js to support both the direct-config flow and the resume-upload flow. Added PDF parsing via pdf-parse and file storage via Cloudinary (uploadToCloudinary) and dynamically inferred the required domain details from the specified job role.
Retrieval Endpoints: Implemented and registered GET /api/interviews/:interviewId (getInterviewById) and GET /api/interviews/:interviewId/session (getInterviewSession) on the backend to allow the interview room to load the scheduled interview's metadata.
Type of Change
🐛 Bug Fix
Testing
Describe the tests you ran to verify your changes.
Tested locally (validated controller, model, and route syntax via node --check to ensure no syntax errors or load issues exist).
No tests required
📸 Screenshots / Video
No UI elements were modified. The fix targets data integration, file uploads, and routing logic.
✅ Checklist
I've read the CONTRIBUTING.md guidelines.
My code follows the project’s conventions.
I've linked the related issue correctly.
I've tested my changes locally.
I've added or updated documentation/comments if needed.
My PR title follows the branch & commit naming conventions.
My changes introduce no new warnings or errors.
I've performed a self-review of my work.