Github access test
This commit is contained in:
@@ -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);
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user