diff --git a/src/app/page.tsx b/src/app/page.tsx index 3626446..f0089d9 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -2,7 +2,8 @@ import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import redirectAuth from "@/lib/dockship/redirect"; +import { Input } from "@/components/ui/input"; +import { redirectAuth, manualAuth } from "@/lib/dockship/auth"; import { GithubIcon } from "lucide-react"; import Image from "next/image"; @@ -24,10 +25,25 @@ export default function LogIn() { /> - + +
+
+ +
+
+ OR +
+
+ { + if (e.key === "Enter") + manualAuth((e.target as HTMLInputElement).value); + }} + />
diff --git a/src/lib/dockship/redirect.ts b/src/lib/dockship/auth.ts similarity index 60% rename from src/lib/dockship/redirect.ts rename to src/lib/dockship/auth.ts index 19208dc..017f799 100644 --- a/src/lib/dockship/redirect.ts +++ b/src/lib/dockship/auth.ts @@ -1,10 +1,10 @@ "use server"; import { client } from "@/core/auth/oauth"; -import { headers } from "next/headers"; +import { cookies, headers } from "next/headers"; import { redirect } from "next/navigation"; -export default async function redirectAuth() { +export async function redirectAuth() { // Get headers of the incoming request const hdrs = await headers(); @@ -22,3 +22,16 @@ export default async function redirectAuth() { redirect(authorizationUri); } + +export async function manualAuth(token: string) { + const c = await cookies(); + + c.set("github_access", token, { + httpOnly: true, + path: "/", + sameSite: "lax", + secure: process.env.NODE_ENV === "production", + }); + + redirect("/overview"); +}