Github access test

This commit is contained in:
2025-12-28 22:42:27 +01:00
parent 568d894061
commit 24e37e5244
2 changed files with 39 additions and 6 deletions
+26
View File
@@ -19,6 +19,9 @@ import Link from "next/link";
import { getLiveNodes } from "@/core/node";
import { useEffect, useState } from "react";
import { Node, NodeLiveData } from "@/lib/types";
import axios from "axios";
import Cookies from "js-cookie";
import { getSession } from "@/core/auth/session";
const recentDeployments = [
{
@@ -99,6 +102,29 @@ export default function OverviewPage() {
};
fetchNodes();
const interval = setInterval(fetchNodes, 3000);
const test = async () => {
const sessionToken = await getSession();
console.log(sessionToken);
// console.log(
// (
// await axios.get("https://api.github.com/user/repos", {
// headers: { Authorization: `Bearer ${sessionToken}` },
// })
// ).data
// );
// console.log(
// (
// await axios.get("https://api.github.com/orgs/orus-dev/repos", {
// headers: { Authorization: `Bearer ${sessionToken}` },
// })
// ).data
// );
};
test();
return () => clearInterval(interval);
}, []);
+13 -6
View File
@@ -1,7 +1,14 @@
import { getIronSession } from "iron-session";
"use server";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
export const session = getIronSession({
password: process.env.SESSION_PASSWORD!,
cookieName: "nextjs_oauth_session",
secure: process.env.NODE_ENV === "production",
});
export async function getSession() {
const c = await cookies();
const accessToken = c.get("github_access")?.value;
if (!accessToken) {
redirect("/");
}
return accessToken;
}