feat: reorganize files and implement ui and sidebar

This commit is contained in:
shadcn 2023-06-11 00:23:23 +04:00
parent 2e80864b84
commit 01dc4520d6
36 changed files with 1347 additions and 462 deletions

28
auth.ts
View file

@ -1,27 +1,27 @@
import NextAuth from "@auth/nextjs";
import GitHub from "@auth/nextjs/providers/github";
import { NextResponse } from "next/server";
import NextAuth from '@auth/nextjs'
import GitHub from '@auth/nextjs/providers/github'
import { NextResponse } from 'next/server'
export const {
handlers: { GET, POST },
auth,
CSRF_experimental,
CSRF_experimental
} = NextAuth({
// @ts-ignore
providers: [GitHub],
session: { strategy: "jwt" },
session: { strategy: 'jwt' },
async authorized({ request, auth }: any) {
const url = request.nextUrl;
const url = request.nextUrl
if (request.method === "POST") {
const { authToken } = (await request.json()) ?? {};
if (request.method === 'POST') {
const { authToken } = (await request.json()) ?? {}
// If the request has a valid auth token, it is authorized
const valid = true;
if (valid) return true;
return NextResponse.json("Invalid auth token", { status: 401 });
const valid = true
if (valid) return true
return NextResponse.json('Invalid auth token', { status: 401 })
}
// Logged in users are authenticated, otherwise redirect to login page
return !!auth;
},
});
return !!auth
}
})