Fix onboarding create/update flow and validation - #30
Open
Linda-riziki wants to merge 1 commit into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for skillsyncglobal ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Summary
This PR fixes the onboarding flow so users can safely complete onboarding multiple times without causing server errors. Instead of always creating a new
user_goalsrecord, the API now creates a record on the first submission and updates the existing record on subsequent submissions.What changed
Replaced the insert-only onboarding logic with an authenticated create-or-update flow keyed by the authenticated user.
Added shared server-side validation for all onboarding fields.
Improved API responses by returning appropriate 400 and 401 errors instead of generic 500 errors for invalid or unauthorized requests.
Preserved existing onboarding completion behavior and SOC binding semantics.
Updated the database logic to correctly handle onboarding updates for existing users.
Added automated tests covering:
Verification
npm testResult:
These tests verify that onboarding is idempotent, validates incoming data correctly, and returns appropriate responses for authorized and unauthorized requests.
If you'd like, I can also make it match the style used by the repository's previous PRs.