fix adminwrap issue
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { isAdmin } from "~/app/actions"
|
||||
|
||||
export default async function AdminWrap({children,}: Readonly<{ children: React.ReactNode }>) {
|
||||
if (await isAdmin()) {
|
||||
// "use client"
|
||||
// import { isAdmin } from "~/app/actions"
|
||||
import { useUser } from "@clerk/nextjs"
|
||||
import { env } from "~/env"
|
||||
export default function AdminWrap({children,}: Readonly<{ children: React.ReactNode }>) {
|
||||
const user = useUser();
|
||||
if (user.isSignedIn && user.user.id == env.NEXT_PUBLIC_ADMIN_USER_CLERK_ID) {
|
||||
return <>{children}</>
|
||||
}
|
||||
return (<></>)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
import Link from "next/link"
|
||||
import AdminWrap from "./AdminWrap"
|
||||
import { Show, SignInButton, SignOutButton, SignUpButton, UserButton } from "@clerk/nextjs"
|
||||
import { ClerkLoaded, Show, SignInButton, SignOutButton, SignUpButton, UserButton } from "@clerk/nextjs"
|
||||
import { Button } from "~/components/ui/button"
|
||||
import { ThemeSwitch } from "./ThemeSwitch"
|
||||
|
||||
@@ -39,13 +40,15 @@ export default function TopNav() {
|
||||
</Button>
|
||||
</Show>
|
||||
<ThemeSwitch />
|
||||
<Show when="signed-in">
|
||||
<Button asChild className="flex h-10 lg:h-full cursor-pointer lg:w-20 content-center" variant={"outline"}>
|
||||
<div>
|
||||
<UserButton />
|
||||
</div>
|
||||
</Button>
|
||||
</Show>
|
||||
<ClerkLoaded>
|
||||
<Show when="signed-in">
|
||||
<Button asChild className="flex h-10 lg:h-full cursor-pointer lg:w-20 content-center" variant={"outline"}>
|
||||
<div>
|
||||
<UserButton />
|
||||
</div>
|
||||
</Button>
|
||||
</Show>
|
||||
</ClerkLoaded>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
@@ -47,7 +47,7 @@ export default function CvPage() {
|
||||
entires[0].filter((e) => { return e.categoryId == cat.id }).length > 0 ? (
|
||||
<>
|
||||
{entires[0].filter((e) => { return e.categoryId == cat.id }).map((entry) => (
|
||||
<CollapsibleForm entityName="Entry" form={CreateUpdateCvEntryForm} entity={entry} entityLabelIndex="title" />
|
||||
<CollapsibleForm key={entry.id} entityName="Entry" form={CreateUpdateCvEntryForm} entity={entry} entityLabelIndex="title" />
|
||||
))}
|
||||
</>
|
||||
) : (<></>)
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function ProjectList() {
|
||||
techStacks[0].filter((e) => { return e.id == project.stackId }).length > 0 ? (
|
||||
<>
|
||||
{techStacks[0].filter((e) => { return e.id == project.stackId }).map((stack) => (
|
||||
<CollapsibleForm entityName="Stack" form={CreateUpdateStackForm} entity={stack} entityLabelIndex="stackItems"/>
|
||||
<CollapsibleForm key={stack.id} entityName="Stack" form={CreateUpdateStackForm} entity={stack} entityLabelIndex="stackItems"/>
|
||||
))}
|
||||
</>
|
||||
) : (<></>)
|
||||
|
||||
@@ -38,6 +38,7 @@ export const env = createEnv({
|
||||
* `NEXT_PUBLIC_`.
|
||||
*/
|
||||
client: {
|
||||
NEXT_PUBLIC_ADMIN_USER_CLERK_ID: z.string(),
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string()
|
||||
// NEXT_PUBLIC_CLIENTVAR: z.string(),
|
||||
},
|
||||
@@ -63,6 +64,7 @@ export const env = createEnv({
|
||||
POSTGRES_URL_NO_SSL: process.env.POSTGRES_URL_NO_SSL,
|
||||
POSTGRES_PRISMA_URL: process.env.POSTGRES_PRISMA_URL,
|
||||
ADMIN_USER_CLERK_ID: process.env.ADMIN_USER_CLERK_ID,
|
||||
NEXT_PUBLIC_ADMIN_USER_CLERK_ID: process.env.NEXT_PUBLIC_ADMIN_USER_CLERK_ID,
|
||||
CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { env } from "~/env";
|
||||
const isTenantAdminRoute = createRouteMatcher(['/admin(.*)'])
|
||||
export default clerkMiddleware(async (auth,req) => {
|
||||
if (isTenantAdminRoute(req)) {
|
||||
console.log("running clerk middleware");
|
||||
let userid = (await auth()).userId
|
||||
if (userid != env.ADMIN_USER_CLERK_ID) {
|
||||
await auth.protect()
|
||||
|
||||
@@ -55,7 +55,7 @@ export const cvEntryRelations = relations(cvEntry, ({one}) => ({
|
||||
|
||||
export const sourceTypeEnum = pgEnum('source_type',['open','closed'])
|
||||
export const releaseStatus = pgEnum('release_status',['released','unreleased'])
|
||||
export const stackItemEnum = pgEnum('stack_item',['drizzle','postgres','nextjs','react','servercomponents','php','laravel','reactnative','expo','mysql','nginx','protobuf','grpc'])
|
||||
export const stackItemEnum = pgEnum('stack_item',['drizzle','postgres','nextjs','react','servercomponents','php','laravel','reactnative','expo','mysql','nginx','protobuf','grpc','java','graalvm','spring','aws','s3','react-native','linux','debian','htmx'])
|
||||
|
||||
export const project = createTable(
|
||||
"project",
|
||||
|
||||
Reference in New Issue
Block a user