mirror of
https://github.com/fosrl/pangolin.git
synced 2025-06-21 04:45:41 +02:00
dont import db in nextjs
This commit is contained in:
parent
b6f67e0f0b
commit
f0cb65f65c
9 changed files with 13838 additions and 15982 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -33,3 +33,4 @@ bin
|
||||||
.secrets
|
.secrets
|
||||||
test_event.json
|
test_event.json
|
||||||
.idea/
|
.idea/
|
||||||
|
package-lock.json
|
||||||
|
|
29749
package-lock.json
generated
29749
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -37,6 +37,8 @@ export type LoginResponse = {
|
||||||
emailVerificationRequired?: boolean;
|
emailVerificationRequired?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export async function login(
|
export async function login(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
|
|
|
@ -6,6 +6,7 @@ import * as badger from "./badger";
|
||||||
import * as auth from "@server/routers/auth";
|
import * as auth from "@server/routers/auth";
|
||||||
import * as supporterKey from "@server/routers/supporterKey";
|
import * as supporterKey from "@server/routers/supporterKey";
|
||||||
import * as license from "@server/routers/license";
|
import * as license from "@server/routers/license";
|
||||||
|
import * as idp from "@server/routers/idp";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import {
|
import {
|
||||||
verifyResourceAccess,
|
verifyResourceAccess,
|
||||||
|
@ -38,10 +39,11 @@ internalRouter.get(
|
||||||
supporterKey.isSupporterKeyVisible
|
supporterKey.isSupporterKeyVisible
|
||||||
);
|
);
|
||||||
|
|
||||||
internalRouter.get(
|
internalRouter.get(`/license/status`, license.getLicenseStatus);
|
||||||
`/license/status`,
|
|
||||||
license.getLicenseStatus
|
internalRouter.get("/idp", idp.listIdps);
|
||||||
);
|
|
||||||
|
internalRouter.get("/idp/:idpId", idp.getIdp);
|
||||||
|
|
||||||
// Gerbil routes
|
// Gerbil routes
|
||||||
const gerbilRouter = Router();
|
const gerbilRouter = Router();
|
||||||
|
|
|
@ -44,7 +44,6 @@ import {
|
||||||
CreateOrgApiKeyBody,
|
CreateOrgApiKeyBody,
|
||||||
CreateOrgApiKeyResponse
|
CreateOrgApiKeyResponse
|
||||||
} from "@server/routers/apiKeys";
|
} from "@server/routers/apiKeys";
|
||||||
import { ApiKey } from "@server/db";
|
|
||||||
import {
|
import {
|
||||||
InfoSection,
|
InfoSection,
|
||||||
InfoSectionContent,
|
InfoSectionContent,
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import ValidateOidcToken from "./ValidateOidcToken";
|
import ValidateOidcToken from "./ValidateOidcToken";
|
||||||
import { idp } from "@server/db";
|
import { cache } from "react";
|
||||||
import { db } from "@server/db";
|
import { priv } from "@app/lib/api";
|
||||||
import { eq } from "drizzle-orm";
|
import { AxiosResponse } from "axios";
|
||||||
|
import { GetIdpResponse } from "@server/routers/idp";
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export default async function Page(props: {
|
export default async function Page(props: {
|
||||||
params: Promise<{ orgId: string; idpId: string }>;
|
params: Promise<{ orgId: string; idpId: string }>;
|
||||||
|
@ -17,13 +20,14 @@ export default async function Page(props: {
|
||||||
const allCookies = await cookies();
|
const allCookies = await cookies();
|
||||||
const stateCookie = allCookies.get("p_oidc_state")?.value;
|
const stateCookie = allCookies.get("p_oidc_state")?.value;
|
||||||
|
|
||||||
// query db directly in server component because just need the name
|
|
||||||
const [idpRes] = await db
|
|
||||||
.select({ name: idp.name })
|
|
||||||
.from(idp)
|
|
||||||
.where(eq(idp.idpId, parseInt(params.idpId!)));
|
|
||||||
|
|
||||||
if (!idpRes) {
|
const idpRes = await cache(
|
||||||
|
async () => await priv.get<AxiosResponse<GetIdpResponse>>(`/idp/${params.idpId}`)
|
||||||
|
)();
|
||||||
|
|
||||||
|
const foundIdp = idpRes.data?.data?.idp;
|
||||||
|
|
||||||
|
if (!foundIdp) {
|
||||||
return <div>IdP not found</div>;
|
return <div>IdP not found</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +39,7 @@ export default async function Page(props: {
|
||||||
code={searchParams.code}
|
code={searchParams.code}
|
||||||
expectedState={searchParams.state}
|
expectedState={searchParams.state}
|
||||||
stateCookie={stateCookie}
|
stateCookie={stateCookie}
|
||||||
idp={{ name: idpRes.name }}
|
idp={{ name: foundIdp.name }}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,9 +6,11 @@ import DashboardLoginForm from "./DashboardLoginForm";
|
||||||
import { Mail } from "lucide-react";
|
import { Mail } from "lucide-react";
|
||||||
import { pullEnv } from "@app/lib/pullEnv";
|
import { pullEnv } from "@app/lib/pullEnv";
|
||||||
import { cleanRedirect } from "@app/lib/cleanRedirect";
|
import { cleanRedirect } from "@app/lib/cleanRedirect";
|
||||||
import { db } from "@server/db";
|
|
||||||
import { idp } from "@server/db";
|
import { idp } from "@server/db";
|
||||||
import { LoginFormIDP } from "@app/components/LoginForm";
|
import { LoginFormIDP } from "@app/components/LoginForm";
|
||||||
|
import { priv } from "@app/lib/api";
|
||||||
|
import { AxiosResponse } from "axios";
|
||||||
|
import { ListIdpsResponse } from "@server/routers/idp";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
|
@ -34,8 +36,10 @@ export default async function Page(props: {
|
||||||
redirectUrl = cleanRedirect(searchParams.redirect as string);
|
redirectUrl = cleanRedirect(searchParams.redirect as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
const idps = await db.select().from(idp);
|
const idpsRes = await cache(
|
||||||
const loginIdps = idps.map((idp) => ({
|
async () => await priv.get<AxiosResponse<ListIdpsResponse>>("/idp")
|
||||||
|
)();
|
||||||
|
const loginIdps = idpsRes.data.data.idps.map((idp) => ({
|
||||||
idpId: idp.idpId,
|
idpId: idp.idpId,
|
||||||
name: idp.name
|
name: idp.name
|
||||||
})) as LoginFormIDP[];
|
})) as LoginFormIDP[];
|
||||||
|
|
|
@ -14,8 +14,9 @@ import ResourceAccessDenied from "./ResourceAccessDenied";
|
||||||
import AccessToken from "./AccessToken";
|
import AccessToken from "./AccessToken";
|
||||||
import { pullEnv } from "@app/lib/pullEnv";
|
import { pullEnv } from "@app/lib/pullEnv";
|
||||||
import { LoginFormIDP } from "@app/components/LoginForm";
|
import { LoginFormIDP } from "@app/components/LoginForm";
|
||||||
import { db } from "@server/db";
|
import { ListIdpsResponse } from "@server/routers/idp";
|
||||||
import { idp } from "@server/db";
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export default async function ResourceAuthPage(props: {
|
export default async function ResourceAuthPage(props: {
|
||||||
params: Promise<{ resourceId: number }>;
|
params: Promise<{ resourceId: number }>;
|
||||||
|
@ -130,8 +131,10 @@ export default async function ResourceAuthPage(props: {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const idps = await db.select().from(idp);
|
const idpsRes = await cache(
|
||||||
const loginIdps = idps.map((idp) => ({
|
async () => await priv.get<AxiosResponse<ListIdpsResponse>>("/idp")
|
||||||
|
)();
|
||||||
|
const loginIdps = idpsRes.data.data.idps.map((idp) => ({
|
||||||
idpId: idp.idpId,
|
idpId: idp.idpId,
|
||||||
name: idp.name
|
name: idp.name
|
||||||
})) as LoginFormIDP[];
|
})) as LoginFormIDP[];
|
||||||
|
|
|
@ -104,12 +104,12 @@ export function useDockerSocket(site: Site) {
|
||||||
console.warn(
|
console.warn(
|
||||||
"Max retry attempts reached. Containers may still be loading."
|
"Max retry attempts reached. Containers may still be loading."
|
||||||
);
|
);
|
||||||
toast({
|
// toast({
|
||||||
variant: "destructive",
|
// variant: "destructive",
|
||||||
title: "Containers not ready",
|
// title: "Containers not ready",
|
||||||
description:
|
// description:
|
||||||
"Containers are still loading. Please try again in a moment."
|
// "Containers are still loading. Please try again in a moment."
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error(
|
console.error(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue