Manual auth
This commit is contained in:
+18
-2
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
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 { GithubIcon } from "lucide-react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
||||||
@@ -24,10 +25,25 @@ export default function LogIn() {
|
|||||||
/>
|
/>
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent className="flex max-w-sm flex-col gap-4">
|
||||||
<Button className="w-full" onClick={withGithub}>
|
<Button className="w-full" onClick={withGithub}>
|
||||||
<GithubIcon /> Continue with GitHub
|
<GithubIcon /> Continue with GitHub
|
||||||
</Button>
|
</Button>
|
||||||
|
<div className="relative">
|
||||||
|
<div className="absolute inset-0 flex items-center">
|
||||||
|
<span className="w-full border-t" />
|
||||||
|
</div>
|
||||||
|
<div className="relative flex justify-center text-xs uppercase">
|
||||||
|
<span className="bg-card px-2 text-muted-foreground">OR</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
placeholder="Access token"
|
||||||
|
onKeyUp={(e) => {
|
||||||
|
if (e.key === "Enter")
|
||||||
|
manualAuth((e.target as HTMLInputElement).value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import { client } from "@/core/auth/oauth";
|
import { client } from "@/core/auth/oauth";
|
||||||
import { headers } from "next/headers";
|
import { cookies, headers } from "next/headers";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function redirectAuth() {
|
export async function redirectAuth() {
|
||||||
// Get headers of the incoming request
|
// Get headers of the incoming request
|
||||||
const hdrs = await headers();
|
const hdrs = await headers();
|
||||||
|
|
||||||
@@ -22,3 +22,16 @@ export default async function redirectAuth() {
|
|||||||
|
|
||||||
redirect(authorizationUri);
|
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");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user