@@ -5,7 +5,7 @@ import { withDefaults } from '../src/args'
55const authenticatedQuery = 'authenticated'
66const allowedQuery = 'allowed'
77
8- export const onRequestGet = async ( context : EventPluginContext < Record < string , string | undefined > , any , any , PluginArgs > ) : Promise < Response > => {
8+ export const onRequestGet = ( context : EventPluginContext < Record < string , string | undefined > , any , any , PluginArgs > ) : Response | Promise < Response > => {
99 const { request, env, pluginArgs, next } = context
1010
1111 // Get the arguments given to the Plugin by the developer
@@ -20,21 +20,19 @@ export const onRequestGet = async (context: EventPluginContext<Record<string, st
2020
2121 console . debug ( 'Proxy to login form' , url . toString ( ) )
2222
23- return await env . ASSETS . fetch ( new Request ( url , request ) )
23+ return env . ASSETS . fetch ( new Request ( url , request ) )
2424 }
2525
26- return await next ( )
26+ return next ( )
2727}
2828
29- export const onRequestPost = async ( { request, pluginArgs } : EventPluginContext < Record < string , string | undefined > , any , any , PluginArgs > ) : Promise < Response > => {
29+ export const onRequestPost = ( { request, pluginArgs } : EventPluginContext < Record < string , string | undefined > , any , any , PluginArgs > ) : Response | Promise < Response > => {
3030 // Get the arguments given to the Plugin by the developer
3131 const { cookieName, cookieSecret, login, isValid } = withDefaults ( pluginArgs )
3232
3333 const session = new Session ( cookieName , cookieSecret , isValid )
3434
3535 if ( session . valid ( request ) ) {
36- await request . body ?. cancel ( )
37-
3836 return new Response ( 'Already logged in' , {
3937 status : 302 ,
4038 headers : {
@@ -45,7 +43,7 @@ export const onRequestPost = async ({ request, pluginArgs }: EventPluginContext<
4543
4644 const url = new URL ( request . url )
4745
48- return await request . formData ( )
46+ return request . formData ( )
4947 . then ( login )
5048 . then ( ( { authenticated, allowed, cookie } : SessionSpec ) : Response => {
5149 url . searchParams . set ( authenticatedQuery , authenticated . toString ( ) )
0 commit comments