Move to clerk

This commit is contained in:
Jared Palmer 2023-06-13 17:31:15 -04:00
parent cd340320b7
commit 567b0ac313
18 changed files with 550 additions and 178 deletions

27
auth.ts
View file

@ -1,27 +0,0 @@
import { NextResponse } from 'next/server'
import NextAuth from '@auth/nextjs'
import GitHub from '@auth/nextjs/providers/github'
export const {
handlers: { GET, POST },
auth,
CSRF_experimental
} = NextAuth({
// @ts-ignore
providers: [GitHub],
session: { strategy: 'jwt' },
async authorized({ request, auth }: any) {
const url = request.nextUrl
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 })
}
// Logged in users are authenticated, otherwise redirect to login page
return !!auth
}
})