fix adminwrap issue
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
import { isAdmin } from "~/app/actions"
|
// "use client"
|
||||||
|
// import { isAdmin } from "~/app/actions"
|
||||||
export default async function AdminWrap({children,}: Readonly<{ children: React.ReactNode }>) {
|
import { useUser } from "@clerk/nextjs"
|
||||||
if (await isAdmin()) {
|
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 <>{children}</>
|
||||||
}
|
}
|
||||||
return (<></>)
|
return (<></>)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
"use client"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import AdminWrap from "./AdminWrap"
|
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 { Button } from "~/components/ui/button"
|
||||||
import { ThemeSwitch } from "./ThemeSwitch"
|
import { ThemeSwitch } from "./ThemeSwitch"
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ export default function TopNav() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Show>
|
</Show>
|
||||||
<ThemeSwitch />
|
<ThemeSwitch />
|
||||||
|
<ClerkLoaded>
|
||||||
<Show when="signed-in">
|
<Show when="signed-in">
|
||||||
<Button asChild className="flex h-10 lg:h-full cursor-pointer lg:w-20 content-center" variant={"outline"}>
|
<Button asChild className="flex h-10 lg:h-full cursor-pointer lg:w-20 content-center" variant={"outline"}>
|
||||||
<div>
|
<div>
|
||||||
@@ -46,6 +48,7 @@ export default function TopNav() {
|
|||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
</Show>
|
</Show>
|
||||||
|
</ClerkLoaded>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</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 }).length > 0 ? (
|
||||||
<>
|
<>
|
||||||
{entires[0].filter((e) => { return e.categoryId == cat.id }).map((entry) => (
|
{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 }).length > 0 ? (
|
||||||
<>
|
<>
|
||||||
{techStacks[0].filter((e) => { return e.id == project.stackId }).map((stack) => (
|
{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_`.
|
* `NEXT_PUBLIC_`.
|
||||||
*/
|
*/
|
||||||
client: {
|
client: {
|
||||||
|
NEXT_PUBLIC_ADMIN_USER_CLERK_ID: z.string(),
|
||||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string()
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string()
|
||||||
// NEXT_PUBLIC_CLIENTVAR: 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_URL_NO_SSL: process.env.POSTGRES_URL_NO_SSL,
|
||||||
POSTGRES_PRISMA_URL: process.env.POSTGRES_PRISMA_URL,
|
POSTGRES_PRISMA_URL: process.env.POSTGRES_PRISMA_URL,
|
||||||
ADMIN_USER_CLERK_ID: process.env.ADMIN_USER_CLERK_ID,
|
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,
|
CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
|
||||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
|
||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { env } from "~/env";
|
|||||||
const isTenantAdminRoute = createRouteMatcher(['/admin(.*)'])
|
const isTenantAdminRoute = createRouteMatcher(['/admin(.*)'])
|
||||||
export default clerkMiddleware(async (auth,req) => {
|
export default clerkMiddleware(async (auth,req) => {
|
||||||
if (isTenantAdminRoute(req)) {
|
if (isTenantAdminRoute(req)) {
|
||||||
|
console.log("running clerk middleware");
|
||||||
let userid = (await auth()).userId
|
let userid = (await auth()).userId
|
||||||
if (userid != env.ADMIN_USER_CLERK_ID) {
|
if (userid != env.ADMIN_USER_CLERK_ID) {
|
||||||
await auth.protect()
|
await auth.protect()
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const cvEntryRelations = relations(cvEntry, ({one}) => ({
|
|||||||
|
|
||||||
export const sourceTypeEnum = pgEnum('source_type',['open','closed'])
|
export const sourceTypeEnum = pgEnum('source_type',['open','closed'])
|
||||||
export const releaseStatus = pgEnum('release_status',['released','unreleased'])
|
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(
|
export const project = createTable(
|
||||||
"project",
|
"project",
|
||||||
|
|||||||
Reference in New Issue
Block a user