mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
20 lines
519 B
TypeScript
20 lines
519 B
TypeScript
import { github } from '$lib/server/auth'
|
|
import { redirect } from '@sveltejs/kit'
|
|
import { generateState } from 'arctic'
|
|
|
|
import type { RequestEvent } from '@sveltejs/kit'
|
|
|
|
export async function GET(event: RequestEvent): Promise<Response> {
|
|
const state = generateState()
|
|
const url = await github.createAuthorizationURL(state)
|
|
|
|
event.cookies.set('github_oauth_state', state, {
|
|
path: '/',
|
|
secure: import.meta.env.PROD,
|
|
httpOnly: true,
|
|
maxAge: 60 * 10,
|
|
sameSite: 'lax',
|
|
})
|
|
|
|
redirect(302, url.toString())
|
|
}
|