From e287d0163e57e26b668e844be4a9c022c198b6b5 Mon Sep 17 00:00:00 2001 From: "HanuCh@udhary" <137854084+hanuchaudhary@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:04:56 +0530 Subject: [PATCH 1/3] middleware fix --- utils/supabase/middleware.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/supabase/middleware.ts b/utils/supabase/middleware.ts index 3ab112a..5ec4bd5 100644 --- a/utils/supabase/middleware.ts +++ b/utils/supabase/middleware.ts @@ -47,6 +47,15 @@ export async function updateSession(request: NextRequest) { // return NextResponse.redirect(url) // } + //if no user and user try to hit any route other than /auth/signin or /auth/signup or /, redirect to /auth/signin + if (!user && !request.nextUrl.pathname.startsWith('/auth/signin') && !request.nextUrl.pathname.startsWith('/auth/signup') && request.nextUrl.pathname !== '/') { + const url = request.nextUrl.clone() + url.pathname = '/auth/signin' + return NextResponse.redirect(url) + } + + + if ( user && (request.nextUrl.pathname === '/' || From 5a664da4be2936f172308423f3737e5833852adb Mon Sep 17 00:00:00 2001 From: "HanuCh@udhary" <137854084+hanuchaudhary@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:27:35 +0530 Subject: [PATCH 2/3] logout fix --- components/dashboardComponents/AppSidebar.tsx | 7 +++---- package-lock.json | 13 +++++++++++-- package.json | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/components/dashboardComponents/AppSidebar.tsx b/components/dashboardComponents/AppSidebar.tsx index b967e56..f370b51 100644 --- a/components/dashboardComponents/AppSidebar.tsx +++ b/components/dashboardComponents/AppSidebar.tsx @@ -16,6 +16,7 @@ import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { SidebarData } from "@/data/SidebarData"; import { supabase } from "@/lib/supabaseClient"; +import { signout } from "@/app/actions/action"; export function AppSidebar() { const { setTheme, theme } = useTheme(); @@ -24,13 +25,11 @@ export function AppSidebar() { const [isCollapsed, setIsCollapsed] = React.useState(false); const handleLogout = async () => { try { - const { error } = await supabase.auth.signOut(); - if (error) throw error; + signout(); router.push('/auth/signin'); } catch (error) { console.error("Sign out error:", error); - } - // Fix the Logout functionality, something is wrong here, It keeps throwing a 307 error on logout,and the user is not redirected to the login page + } }; return ( diff --git a/package-lock.json b/package-lock.json index 3e51012..38ad1a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,6 @@ "@radix-ui/react-tooltip": "^1.1.6", "@supabase/ssr": "^0.5.2", "@types/bcryptjs": "^2.4.6", - "@types/express": "^5.0.0", "@types/react-chartjs-2": "^2.0.2", "axios": "^1.7.9", "bcryptjs": "^2.4.3", @@ -48,6 +47,7 @@ "@eslint/eslintrc": "^3", "@supabase/auth-helpers-nextjs": "^0.10.0", "@supabase/supabase-js": "^2.47.11", + "@types/express": "^5.0.0", "@types/node": "^20", "@types/react": "^19", "@types/react-dom": "^19", @@ -1971,6 +1971,7 @@ "version": "1.19.5", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", + "dev": true, "license": "MIT", "dependencies": { "@types/connect": "*", @@ -1990,6 +1991,7 @@ "version": "3.4.38", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, "license": "MIT", "dependencies": { "@types/node": "*" @@ -2011,7 +2013,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.0.tgz", "integrity": "sha512-DvZriSMehGHL1ZNLzi6MidnsDhUZM/x2pRdDIKdwbUNqqwHxMlRdkxtn6/EPKyqKpHqTl/4nRZsRNLpZxZRpPQ==", - "license": "MIT", + "dev": true, "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^5.0.0", @@ -2023,6 +2025,7 @@ "version": "5.0.5", "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.5.tgz", "integrity": "sha512-GLZPrd9ckqEBFMcVM/qRFAP0Hg3qiVEojgEFsx/N/zKXsBzbGF6z5FBDpZ0+Xhp1xr+qRZYjfGr1cWHB9oFHSA==", + "dev": true, "license": "MIT", "dependencies": { "@types/node": "*", @@ -2035,6 +2038,7 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==", + "dev": true, "license": "MIT" }, "node_modules/@types/json-schema": { @@ -2055,6 +2059,7 @@ "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true, "license": "MIT" }, "node_modules/@types/node": { @@ -2076,12 +2081,14 @@ "version": "6.9.18", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.18.tgz", "integrity": "sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA==", + "dev": true, "license": "MIT" }, "node_modules/@types/range-parser": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true, "license": "MIT" }, "node_modules/@types/react": { @@ -2117,6 +2124,7 @@ "version": "0.17.4", "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", + "dev": true, "license": "MIT", "dependencies": { "@types/mime": "^1", @@ -2127,6 +2135,7 @@ "version": "1.15.7", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz", "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==", + "dev": true, "license": "MIT", "dependencies": { "@types/http-errors": "*", diff --git a/package.json b/package.json index 21abcf6..d285cd7 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "@radix-ui/react-tooltip": "^1.1.6", "@supabase/ssr": "^0.5.2", "@types/bcryptjs": "^2.4.6", - "@types/express": "^5.0.0", "@types/react-chartjs-2": "^2.0.2", "axios": "^1.7.9", "bcryptjs": "^2.4.3", @@ -49,6 +48,7 @@ "@eslint/eslintrc": "^3", "@supabase/auth-helpers-nextjs": "^0.10.0", "@supabase/supabase-js": "^2.47.11", + "@types/express": "^5.0.0", "@types/node": "^20", "@types/react": "^19", "@types/react-dom": "^19", From 8665d3974c9f450585e85102e1b6b1e783bd877b Mon Sep 17 00:00:00 2001 From: "HanuCh@udhary" <137854084+hanuchaudhary@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:29:51 +0530 Subject: [PATCH 3/3] bg fix --- app/dashboard/profile/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/dashboard/profile/page.tsx b/app/dashboard/profile/page.tsx index 01b7a64..342b064 100644 --- a/app/dashboard/profile/page.tsx +++ b/app/dashboard/profile/page.tsx @@ -13,7 +13,7 @@ function DashboardContent({ authUser }: any) { return (

Welcome, {authUser?.fullName}

- + Your Profile @@ -75,7 +75,7 @@ export default function Dashboard() { <> {leetcodeStats && ( -
+

Your LeetCode Progress