mirror of
https://github.com/sern-handler/frontpage-bot
synced 2026-06-06 01:16:54 +00:00
chore: move to /auth/login route
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
"@radix-ui/react-slot": "^1.0.2",
|
||||
"@radix-ui/react-switch": "^1.0.3",
|
||||
"@sern/poster": "^1.2.6",
|
||||
"arctic": "^1.8.1",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.0",
|
||||
"lucia": "^3.1.1",
|
||||
|
||||
@@ -16,6 +16,7 @@ datasource db {
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
username String @unique
|
||||
discord_id String @unique
|
||||
hashed_password String
|
||||
isAdmin Boolean @default(false)
|
||||
sessions Session[]
|
||||
|
||||
@@ -5,7 +5,7 @@ import { redirect } from "next/navigation";
|
||||
|
||||
export default async function Page() {
|
||||
const { user } = await validateRequest()
|
||||
if (!user) return redirect('/auth/signIn')
|
||||
if (!user) return redirect('/auth/login')
|
||||
if (!user.isAdmin) return (
|
||||
<h1 className="text-center font-extrabold text-6xl">Sorry</h1>
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ export default function Page() {
|
||||
<SubmitButton buttonText="Create account" className="w-full" />
|
||||
<div className="text-center text-sm">
|
||||
Already have an account?
|
||||
<Link className="underline pl-1" href="/auth/signIn">
|
||||
<Link className="underline pl-1" href="/auth/login">
|
||||
Login
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { nullsToUndefined } from "@/lib/utils";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const { user } = await validateRequest()
|
||||
if (!user) return redirect('/auth/signIn')
|
||||
if (!user) return redirect('/auth/login')
|
||||
|
||||
const dbFetch = await prisma.bot.findUnique({
|
||||
where: {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { redirect } from "next/navigation";
|
||||
|
||||
export default async function Page() {
|
||||
const { user } = await validateRequest()
|
||||
if (!user) return redirect('/auth/signIn')
|
||||
if (!user) return redirect('/auth/login')
|
||||
|
||||
const dbFetch = await prisma.bot.findMany({
|
||||
where: {
|
||||
|
||||
@@ -80,7 +80,7 @@ export default function Navbar() {
|
||||
</DropdownMenu>
|
||||
</>
|
||||
) : (
|
||||
<Link href="/auth/signIn">
|
||||
<Link href="/auth/login">
|
||||
<Button variant="outline">Sign in</Button>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
@@ -13,7 +13,7 @@ export async function logout() {
|
||||
await lucia.invalidateSession(session!.id);
|
||||
const sessionCookie = lucia.createBlankSessionCookie();
|
||||
cookies().set(sessionCookie.name, sessionCookie.value, sessionCookie.attributes);
|
||||
return redirect("/auth/signIn");
|
||||
return redirect("/auth/login");
|
||||
}
|
||||
|
||||
export async function login(prev: any, data: FormData) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Lucia, Session, User } from "lucia";
|
||||
import prisma from "../db";
|
||||
import { cache } from "react";
|
||||
import { cookies } from "next/headers";
|
||||
import { Discord } from 'arctic'
|
||||
|
||||
const adapter = new PrismaAdapter(prisma.session, prisma.user);
|
||||
|
||||
@@ -23,6 +24,9 @@ export const lucia = new Lucia(adapter, {
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export const discord = new Discord(process.env.DSC_CLIENTID!, process.env.DSC_CLIENTSECRET!, process.env.NODE_ENV === "production" ? process.env.DSC_REDIRECTURI! : "http://localhost:3000/api/auth/discord/callback")
|
||||
|
||||
export const validateRequest = cache(async () => {
|
||||
const sessionId = cookies().get(lucia.sessionCookieName)?.value ?? null
|
||||
|
||||
|
||||
@@ -926,6 +926,13 @@ anymatch@~3.1.2:
|
||||
normalize-path "^3.0.0"
|
||||
picomatch "^2.0.4"
|
||||
|
||||
arctic@^1.8.1:
|
||||
version "1.8.1"
|
||||
resolved "https://registry.yarnpkg.com/arctic/-/arctic-1.8.1.tgz#a5ab9f2cd7980760be7a99058f9b9501a5d3cafe"
|
||||
integrity sha512-YmTcSfk8+NDSZt7qWYBX4HrikHZA3EQgmfFYlS4BwtYzPrji2VjAFrCFMElnjp72zmx3J3mz1ldjaXvjxmiW4Q==
|
||||
dependencies:
|
||||
oslo "1.2.0"
|
||||
|
||||
arg@^5.0.2:
|
||||
version "5.0.2"
|
||||
resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c"
|
||||
|
||||
Reference in New Issue
Block a user