feat: ci/cd
This commit is contained in:
@@ -13,7 +13,7 @@ import Applications from "./items/applications";
|
||||
|
||||
interface Props {
|
||||
userData: User | null;
|
||||
consentsData: Consent[] | [];
|
||||
consentsData: Consent[] | null;
|
||||
}
|
||||
|
||||
export default function MeClient({ userData, consentsData }: Props) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { enUS } from "date-fns/locale";
|
||||
import { format } from "date-fns";
|
||||
|
||||
interface Props {
|
||||
consents: Consent[] | [];
|
||||
consents: Consent[] | null;
|
||||
setConsents: (consents: Consent[]) => void;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export default function Applications({ consents, setConsents }: Props) {
|
||||
<h1 className="text-xl">{t("title")}</h1>
|
||||
|
||||
<div className="space-y-4">
|
||||
{consents.map((consent) => (
|
||||
{consents?.map((consent) => (
|
||||
<Item key={consent.client_id}>
|
||||
<ItemContent>
|
||||
<ItemTitle>{consent.client_name}</ItemTitle>
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { getSession } from "@/actions/oauth";
|
||||
import { isRedirectError } from "next/dist/client/components/redirect-error";
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function OAuthPage({
|
||||
searchParams,
|
||||
}: {
|
||||
@@ -14,10 +17,28 @@ export default async function OAuthPage({
|
||||
const data = await getSession(session);
|
||||
if (!data) redirect("/oauth/error");
|
||||
|
||||
const isAuthenticated =
|
||||
data.user_id && data.user_id !== "00000000-0000-0000-0000-000000000000";
|
||||
const store = await cookies();
|
||||
const accessToken = store.get("access_token")?.value;
|
||||
|
||||
redirect(isAuthenticated ? `/consent?session=${session}` : `/login?session=${session}`);
|
||||
if (accessToken) {
|
||||
const res = await fetch(`${process.env.KOTOSOFT_ID_API_URL}/oauth/session/attach`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${accessToken}`
|
||||
},
|
||||
body: JSON.stringify({ session }),
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const body = await res.json();
|
||||
if (body.redirect_url) redirect(body.redirect_url);
|
||||
redirect(`/consent?session=${session}`);
|
||||
}
|
||||
}
|
||||
|
||||
redirect(`/login?session=${session}`);
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) throw error;
|
||||
console.error("OAuth page error:", error);
|
||||
|
||||
Reference in New Issue
Block a user