Skip to content

Commit edd2de9

Browse files
committed
πŸ”§ Fix authentication flow and collaborator management
βœ… Fixed server action import issues (ensureUserProfile) βœ… Fixed collaborator limit logic - only show subscription modal at 2+ collaborators βœ… Replaced all console.log with custom logger helper (production-safe) βœ… Fixed import conflicts between client/server utils βœ… Improved user experience with better plan limit messaging βœ… Added comprehensive debugging for authentication flow βœ… Fixed subscription modal to show actual plans instead of 'contact support' βœ… Updated documentation with working solutions βœ… All authentication issues resolved and tested - Login/signup now works without 404 errors - Collaborator search shows clear plan limits upfront - Subscription modal only appears when actually needed - Production-safe logging implemented throughout - Build, lint, and format all passing
1 parent 6211465 commit edd2de9

File tree

43 files changed

+2554
-895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2554
-895
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ next-env.d.ts
3939
certificates
4040
scripts/
4141

42-
tsconfig.tsbuildinfo
42+
tsconfig.tsbuildinfo
43+
AUTH_QUICK_REFERENCE.md
44+
AUTHENTICATION_TROUBLESHOOTING.md
45+
src/app/api/debug.ts

β€Žpublic/robots.txtβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
User-agent: *
22
Allow: /
3-
Sitemap: https://av-market-place.vercel.app/sitemap.xml
3+
Sitemap: https://collaborative-platform-sepia.vercel.app/sitemap.xml

β€Žpublic/sitemap.xmlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
4-
<loc>https://av-market-place.vercel.app/</loc>
4+
<loc>https://collaborative-platform-sepia.vercel.app/</loc>
55
<priority>1.0</priority>
66
</url>
77
<url>
8-
<loc>https://av-market-place.vercel.app/dashboard</loc>
8+
<loc>https://collaborative-platform-sepia.vercel.app/dashboard</loc>
99
<priority>0.8</priority>
1010
</url>
1111
</urlset>
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
import type { Metadata } from 'next';
2-
import ErrorCard from '@/components/ui/ErrorCard';
1+
// app/auth/auth-code-error/page.jsx
2+
import Link from 'next/link';
33

4-
export const metadata: Metadata = {
5-
title: 'Error | avom-brice realtime collaborative app',
6-
icons: {
7-
icon: '/favicon.ico',
8-
},
9-
};
10-
11-
export default function AuthErrorPage() {
4+
export default function AuthCodeError() {
125
return (
13-
<ErrorCard
14-
title="Authentication Error"
15-
description="Something went wrong during authentication. Please try again or contact support."
16-
actionHref="/"
17-
actionLabel="Back to Home"
18-
/>
6+
<div className="flex flex-col items-center justify-center min-h-screen p-4">
7+
<div className="w-full max-w-md p-8 space-y-8 bg-white rounded-lg shadow-md text-center">
8+
<h1 className="text-2xl font-bold text-red-600">Authentication Error</h1>
9+
<p className="mt-2">We encountered a problem with your authentication.</p>
10+
<div className="mt-6">
11+
<Link href="/login" className="text-blue-600 hover:underline">
12+
Go back to login
13+
</Link>
14+
</div>
15+
</div>
16+
</div>
1917
);
2018
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Metadata } from 'next';
2-
import LoginPage from '@/components/features/auth';
2+
import { Login } from '@/components/features/auth';
33

44
export const metadata: Metadata = {
55
title: 'Login | avom-brice realtime collaborative app',
@@ -8,4 +8,4 @@ export const metadata: Metadata = {
88
},
99
};
1010

11-
export default LoginPage;
11+
export default Login;

β€Žsrc/app/(main)/dashboard/[workspaceId]/[folderId]/[fileId]/page.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getFolderDetails,
77
getWorkspaceDetails,
88
} from '@/lib/supabase/queries';
9-
import { verifyUserAuth, checkWorkspaceAccess, safeRedirect } from '@/lib/utils/auth-utils';
9+
import { verifyUserAuth, checkWorkspaceAccess, safeRedirect } from '@/utils/auth-utils';
1010
import AppStateProvider from '@/lib/providers/state-provider';
1111
import { File, Folder, workspace } from '@/lib/supabase/supabase.types';
1212
import QuillWrapper from '@/components/features/main/quill-editor/quill-wrapper';

β€Žsrc/app/(main)/dashboard/[workspaceId]/[folderId]/page.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import QuillEditor from '@/components/features/main/quill-editor';
33
import { getFolderDetails, getWorkspaceDetails } from '@/lib/supabase/queries';
4-
import { verifyUserAuth, checkWorkspaceAccess, safeRedirect } from '@/lib/utils/auth-utils';
4+
import { verifyUserAuth, checkWorkspaceAccess, safeRedirect } from '@/utils/auth-utils';
55
import AppStateProvider from '@/lib/providers/state-provider';
66
import { Folder, workspace } from '@/lib/supabase/supabase.types';
77
import QuillWrapper from '@/components/features/main/quill-editor/quill-wrapper';

β€Žsrc/app/(main)/dashboard/[workspaceId]/page.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
checkWorkspaceAccess,
88
safeRedirect,
99
getUserPrimaryWorkspace,
10-
} from '@/lib/utils/auth-utils';
10+
} from '@/utils/auth-utils';
1111
import { Button } from '@/components/ui/button';
1212
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
1313
import { AlertCircle, ArrowLeft, Home, Plus } from 'lucide-react';

β€Žsrc/app/(main)/dashboard/layout.tsxβ€Ž

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SubscriptionModalProvider } from '@/lib/providers/subscription-modal-provider';
22
import { getActiveProductsWithPrice } from '@/lib/supabase/queries';
33
import React from 'react';
4+
import { logger } from '@/utils/logger';
45

56
interface LayoutProps {
67
children: React.ReactNode;
@@ -15,14 +16,22 @@ const Layout: React.FC<LayoutProps> = async ({ children, params }) => {
1516

1617
// Handle both error cases: explicit error or null/undefined data
1718
if (result.error || !result.data) {
18-
console.error('error get active product from layout: ', result.error || 'No data returned');
19+
logger.error('error get active product from layout: ', result.error || 'No data returned');
1920
// Use empty products array as fallback
2021
products = [];
2122
} else {
2223
products = result.data || [];
2324
}
25+
26+
// Debug products loading
27+
logger.info('Dashboard Layout - Products loaded:', {
28+
productsCount: products.length,
29+
products: products.map((p) => ({ id: p.id, name: p.name, pricesCount: p.prices?.length })),
30+
hasError: !!result.error,
31+
error: result.error,
32+
});
2433
} catch (error) {
25-
console.error('Unexpected error getting products:', error);
34+
logger.error('Unexpected error getting products:', error);
2635
// Use empty products array as fallback
2736
products = [];
2837
}

β€Žsrc/app/(main)/dashboard/page.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { verifyUserAuth, getUserPrimaryWorkspace, safeRedirect } from '@/lib/utils/auth-utils';
2+
import { verifyUserAuth, getUserPrimaryWorkspace, safeRedirect } from '@/utils/auth-utils';
33
import {
44
getUserSubscriptionStatus,
55
getPrivateWorkspaces,

0 commit comments

Comments
Β (0)