mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
feat(onboarding): gate landing, auth and dashboard routes behind onboarding cookie
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { currentUser } from "@/lib/auth/current-user";
|
import { currentUser } from "@/lib/auth/current-user";
|
||||||
|
import { isOnboardingDone } from "@/features/onboarding/onboarding-cookie";
|
||||||
import { AuthLogoSection } from "@/features/auth/auth-logo-section";
|
import { AuthLogoSection } from "@/features/auth/auth-logo-section";
|
||||||
import { Heart } from "lucide-react";
|
import { Heart } from "lucide-react";
|
||||||
|
|
||||||
@@ -9,6 +10,10 @@ export default async function Layout({
|
|||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
|
if (!(await isOnboardingDone())) {
|
||||||
|
redirect("/welcome");
|
||||||
|
}
|
||||||
|
|
||||||
const user = await currentUser();
|
const user = await currentUser();
|
||||||
|
|
||||||
if (user && !user.banned && user.role !== "pending") {
|
if (user && !user.banned && user.role !== "pending") {
|
||||||
|
|||||||
@@ -5,11 +5,16 @@ import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
|
|||||||
import { AppSidebar } from "@/features/layout/app-sidebar";
|
import { AppSidebar } from "@/features/layout/app-sidebar";
|
||||||
import { Header } from "@/features/layout/header";
|
import { Header } from "@/features/layout/header";
|
||||||
import { currentUser } from "@/lib/auth/current-user";
|
import { currentUser } from "@/lib/auth/current-user";
|
||||||
|
import { isOnboardingDone } from "@/features/onboarding/onboarding-cookie";
|
||||||
import { ThemeMetaUpdater } from "@/features/theme/theme-meta-updater";
|
import { ThemeMetaUpdater } from "@/features/theme/theme-meta-updater";
|
||||||
import { ModeToggle } from "@/features/theme/mode-toggle";
|
import { ModeToggle } from "@/features/theme/mode-toggle";
|
||||||
import { UpdateNotification } from "@/features/updates/update-notification";
|
import { UpdateNotification } from "@/features/updates/update-notification";
|
||||||
|
|
||||||
export default async function Layout({ children }: { children: ReactNode }) {
|
export default async function Layout({ children }: { children: ReactNode }) {
|
||||||
|
if (!(await isOnboardingDone())) {
|
||||||
|
redirect("/welcome");
|
||||||
|
}
|
||||||
|
|
||||||
const user = await currentUser();
|
const user = await currentUser();
|
||||||
if (!user) redirect("/login");
|
if (!user) redirect("/login");
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { getCurrentOrganizationSlug } from "@/features/organizations/organization-cookie";
|
import { getCurrentOrganizationSlug } from "@/features/organizations/organization-cookie";
|
||||||
import { currentUser } from "@/lib/auth/current-user";
|
import { currentUser } from "@/lib/auth/current-user";
|
||||||
|
import { isOnboardingDone } from "@/features/onboarding/onboarding-cookie";
|
||||||
|
|
||||||
export default async function Index() {
|
export default async function Index() {
|
||||||
|
if (!(await isOnboardingDone())) {
|
||||||
|
redirect("/welcome");
|
||||||
|
}
|
||||||
|
|
||||||
const user = await currentUser();
|
const user = await currentUser();
|
||||||
if (user) {
|
if (user) {
|
||||||
const currentOrganizationSlug = await getCurrentOrganizationSlug();
|
const currentOrganizationSlug = await getCurrentOrganizationSlug();
|
||||||
|
|||||||
Reference in New Issue
Block a user