-
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix regressions, security, and architectural inconsistencies #442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
google-labs-jules
wants to merge
14
commits into
fix-oauth-and-credits-integration-2704938752808797816
Choose a base branch
from
fix/regressions-security-architecture-13947295106479740171
base: fix-oauth-and-credits-integration-2704938752808797816
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
19eb620
Fix regressions, security vulnerabilities, and architectural inconsis…
google-labs-jules[bot] 349b637
Fix regressions, security, architectural inconsistencies, and refine UI
google-labs-jules[bot] be439d0
Fix regressions, security, architecture, and UI layout refinements
google-labs-jules[bot] ce41245
Address PR feedback and finalize UI layout refinements
google-labs-jules[bot] 384a31e
Final UI refinements, PR feedback address, and auth fixes
google-labs-jules[bot] 003cbb3
Final fix for UI, Auth, and Security issues
google-labs-jules[bot] 0bcef46
Final resolution for all regressions, security, architecture, and UI …
google-labs-jules[bot] 6cbf8cc
fix: RLS, persistence, and UI (credits + usage sidebar)
ngoiyaeric fd4526e
fix: authentication, chat history toggle, and UI improvements
CJWTRUST fe8dc87
Merge pull request #443 from QueueLab/pr-442
ngoiyaeric aececdf
Address PR feedback: simplify header triggers and verify mobile usage UI
google-labs-jules[bot] 6af0fe0
feat: implement billing UI, authentication flow, chat retrieval, and …
CJWTRUST 160f452
Add files via upload
ngoiyaeric 87a2bb6
Fix regressions in security architecture: update auth, add user upgra…
ngoiyaeric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,7 @@ | ||
| AUTH_DISABLED_FOR_DEV=false | ||
| DATABASE_URL="postgresql://user:password@host:port/db" | ||
|
|
||
| # Server Actions Configuration | ||
| # Allow Server Actions in remote dev environments | ||
| SERVER_ACTIONS_ALLOWED_ORIGINS="*" | ||
|
|
||
| # Authentication Configuration | ||
| # Disable Supabase auth and use mock user for development/preview | ||
| AUTH_DISABLED_FOR_DEV="false" | ||
|
|
||
| # Standard Tier Configuration | ||
| STANDARD_TIER_PRICE_ID="price_standard_41_yearly" | ||
| SERVER_ACTIONS_ALLOWED_ORIGINS=* | ||
| STANDARD_TIER_BILLING_CYCLE="yearly" | ||
| STANDARD_TIER_CREDITS=8000 | ||
| STANDARD_TIER_MONTHLY_PRICE=41 | ||
| STANDARD_TIER_BILLING_CYCLE="yearly" | ||
| STANDARD_TIER_PRICE_ID="price_standard_41_yearly" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,6 @@ | ||
| # Supabase Configuration | ||
| NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co | ||
| NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here | ||
|
|
||
| # Stripe Configuration | ||
| STANDARD_TIER_PRICE_ID=price_placeholder # must be real Stripe price ID in prod | ||
| NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co | ||
| STANDARD_TIER_BILLING_CYCLE="yearly" | ||
| STANDARD_TIER_CREDITS=8000 | ||
| STANDARD_TIER_MONTHLY_PRICE=41 | ||
| STANDARD_TIER_BILLING_CYCLE=yearly | ||
|
|
||
| # Other Environment Variables | ||
| # Add other existing env vars here with placeholder values | ||
| STANDARD_TIER_PRICE_ID="price_placeholder" |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| { | ||
| "editor.formatOnSave": true, | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode", | ||
| "IDX.corgiMode": true | ||
| } | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode" | ||
| } |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { NextRequest, NextResponse } from 'next/server'; | ||
| import { db } from '@/lib/db'; | ||
| import { users } from '@/lib/db/schema'; | ||
| import { eq } from 'drizzle-orm'; | ||
| import { getSupabaseServerClient } from '@/lib/supabase/client'; | ||
| import { TIER_CONFIGS, TIERS, parseTier } from '@/lib/utils/subscription'; | ||
|
|
||
| export async function POST(req: NextRequest) { | ||
| try { | ||
| const supabase = getSupabaseServerClient(); | ||
| const { | ||
| data: { user }, | ||
| error: userError | ||
| } = await supabase.auth.getUser(); | ||
|
|
||
| if (userError || !user) { | ||
| return NextResponse.json( | ||
| { error: 'Unauthorized' }, | ||
| { status: 401 } | ||
| ); | ||
| } | ||
|
|
||
| const { tier } = await req.json(); | ||
|
|
||
| // Validate tier | ||
| if (!tier || !Object.values(TIERS).includes(tier)) { | ||
| return NextResponse.json( | ||
| { error: 'Invalid tier' }, | ||
| { status: 400 } | ||
| ); | ||
| } | ||
|
|
||
| // Get tier config to determine credits to add | ||
| const tierConfig = TIER_CONFIGS[tier as keyof typeof TIER_CONFIGS]; | ||
| if (!tierConfig) { | ||
| return NextResponse.json( | ||
| { error: 'Tier not found' }, | ||
| { status: 400 } | ||
| ); | ||
| } | ||
|
|
||
| // Get current user from database | ||
| const currentUser = await db.query.users.findFirst({ | ||
| where: eq(users.id, user.id) | ||
| }); | ||
|
|
||
| if (!currentUser) { | ||
| return NextResponse.json( | ||
| { error: 'User not found' }, | ||
| { status: 404 } | ||
| ); | ||
| } | ||
|
|
||
| // Calculate credits to add | ||
| const creditsToAdd = tierConfig.credits; | ||
| const newCreditsTotal = currentUser.credits + creditsToAdd; | ||
|
|
||
| // Update user in database with new tier and credits | ||
| const updatedUser = await db | ||
| .update(users) | ||
| .set({ | ||
| tier: tier, | ||
| credits: newCreditsTotal | ||
| }) | ||
| .where(eq(users.id, user.id)) | ||
| .returning(); | ||
|
|
||
| return NextResponse.json({ | ||
| success: true, | ||
| tier: tier, | ||
| creditsAdded: creditsToAdd, | ||
| totalCredits: newCreditsTotal, | ||
| message: `Successfully upgraded to ${tier} tier with ${creditsToAdd} credits` | ||
| }); | ||
|
|
||
| } catch (error) { | ||
| console.error('Error upgrading user:', error); | ||
| return NextResponse.json( | ||
| { error: 'Internal Server Error' }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messageContent: string | any[]reintroducesanyand undermines the benefit of the parsing normalization. Since the downstream component apparently supportsstring | unknown[](or similar), keep it type-safe withoutany.Suggestion
Avoid
anyhere; useunknown[](or a domain type for multimodal chunks).If you know the shape, define a
MultimodalPartunion and useMultimodalPart[].Reply with "@CharlieHelps yes please" if you want me to push a commit that replaces
any[]withunknown[](and optionally adds a small type alias).