File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ export function returnTo(event: RequestEvent) {
7474 let redirectUrl = decodeURIComponent ( event . url . searchParams . get ( 'returnTo' ) ?? '' ) ;
7575 while ( redirectUrl ?. startsWith ( '/login' ) ) {
7676 redirectUrl = decodeURIComponent (
77- new URL ( secrets . ORIGIN , redirectUrl ) . searchParams . get ( 'returnTo' ) ?? ''
77+ new URL ( redirectUrl , secrets . ORIGIN ) . searchParams . get ( 'returnTo' ) ?? ''
7878 ) ;
7979 }
8080 throw redirect (
@@ -102,12 +102,9 @@ export async function tryVerifyAPIToken(
102102 }
103103 const client = await prisma . client . findFirst ( { where : { access_token } } ) ;
104104 if ( ! client ) {
105- if (
106- timingSafeEqual (
107- Buffer . from ( access_token , 'hex' ) ,
108- Buffer . from ( secrets . API_ACCESS_TOKEN , 'hex' )
109- )
110- ) {
105+ const a = Buffer . from ( access_token , 'hex' ) ;
106+ const b = Buffer . from ( secrets . API_ACCESS_TOKEN , 'hex' ) ;
107+ if ( a . length === b . length && timingSafeEqual ( a , b ) ) {
111108 return [ true , null ] ;
112109 }
113110 return [ false , ErrorResponse ( 403 , 'Invalid Access Token' ) ] ;
You can’t perform that action at this time.
0 commit comments