Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

some refactor

Kiran K56349f51c494
diff --git a/apps/web/app/api/oauth/token/exchange-code-for-token.ts b/apps/web/app/api/oauth/token/exchange-code-for-token.ts
index 3e10fae732..f55b3c401f 100644
--- a/apps/web/app/api/oauth/token/exchange-code-for-token.ts
+++ b/apps/web/app/api/oauth/token/exchange-code-for-token.ts
@@ -69,28 +69,31 @@ export const exchangeAuthCodeForToken = async (
});
}
- if (app.pkce && !codeVerifier) {
- throw new DubApiError({
- code: "bad_request",
- message: "Missing code_verifier parameter",
- });
+ // When PKCE is enabled, the code_verifier is required
+ if (app.pkce) {
+ if (!codeVerifier) {
+ throw new DubApiError({
+ code: "bad_request",
+ message: "Missing code_verifier parameter",
+ });
+ }
}
- if (!app.pkce && !clientSecret) {
- throw new DubApiError({
- code: "unauthorized",
- message: "Missing client_secret",
- });
- }
+ // When PKCE is not enabled, the client_secret is required
+ else if (!app.pkce) {
+ if (!clientSecret) {
+ throw new DubApiError({
+ code: "unauthorized",
+ message: "Missing client_secret",
+ });
+ }
- if (
- clientSecret &&
- app.clientSecretHashed !== (await hashToken(clientSecret))
- ) {
- throw new DubApiError({
- code: "unauthorized",
- message: "Invalid client_secret",
- });
+ if (app.clientSecretHashed !== (await hashToken(clientSecret))) {
+ throw new DubApiError({
+ code: "unauthorized",
+ message: "Invalid client_secret",
+ });
+ }
}
// Now let's find the access code and validate it
diff --git a/apps/web/app/api/oauth/token/refresh-access-token.ts b/apps/web/app/api/oauth/token/refresh-access-token.ts
index 2696b19ffe..166820cac6 100644
--- a/apps/web/app/api/oauth/token/refresh-access-token.ts
+++ b/apps/web/app/api/oauth/token/refresh-access-token.ts
@@ -86,9 +86,6 @@ export const refreshAccessToken = async (
where: {
clientId,
refreshTokenHashed: await hashToken(refresh_token),
- // expiresAt: {
- // gte: new Date(),
- // },
},
select: {
id: true,