Skip to content

Commit 7d2fff3

Browse files
committed
Resolve Devin feedback
1 parent 49c243b commit 7d2fff3

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/lib/server/auth.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff 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')];

0 commit comments

Comments
 (0)