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.

fix Server Actions must be async functions

Steven Teyaedf1efb0c3a
diff --git a/apps/web/lib/actions/create-user-account.ts b/apps/web/lib/actions/create-user-account.ts
index 38c1080aa9..be157bc27c 100644
--- a/apps/web/lib/actions/create-user-account.ts
+++ b/apps/web/lib/actions/create-user-account.ts
@@ -21,7 +21,7 @@ const OTP_LOCKOUT_DURATION = "24 h"; // Block for 24 hours
// Sign up a new user using email and password
export const createUserAccountAction = actionClient
.schema(schema, {
- handleValidationErrorsShape: (ve) =>
+ handleValidationErrorsShape: async (ve) =>
flattenValidationErrors(ve).fieldErrors,
})
.use(throwIfAuthenticated)
diff --git a/apps/web/lib/actions/partners/update-online-presence.ts b/apps/web/lib/actions/partners/update-online-presence.ts
index 1c94861166..1ace098d79 100644
--- a/apps/web/lib/actions/partners/update-online-presence.ts
+++ b/apps/web/lib/actions/partners/update-online-presence.ts
@@ -65,7 +65,7 @@ const updateOnlinePresenceResponseSchema = updateOnlinePresenceSchema.merge(
export const updateOnlinePresenceAction = authPartnerActionClient
.schema(
updateOnlinePresenceSchema.refine(
- (data) => {
+ async (data) => {
return !data.website || isValidUrl(data.website);
},
{
@@ -171,12 +171,16 @@ export const updateOnlinePresenceAction = authPartnerActionClient
await generateCodeChallengeHash(codeVerifier);
// Store code verifier in cookie
- (await cookies()).set("online_presence_code_verifier", codeVerifier, {
- httpOnly: true,
- secure: process.env.NODE_ENV === "production",
- sameSite: "lax",
- maxAge: 60 * 5, // 5 minutes
- });
+ (await cookies()).set(
+ "online_presence_code_verifier",
+ codeVerifier,
+ {
+ httpOnly: true,
+ secure: process.env.NODE_ENV === "production",
+ sameSite: "lax",
+ maxAge: 60 * 5, // 5 minutes
+ },
+ );
params.code_challenge = codeChallenge;
params.code_challenge_method = "S256";
diff --git a/apps/web/lib/actions/request-password-reset.ts b/apps/web/lib/actions/request-password-reset.ts
index 48b021cae5..965b66bf60 100644
--- a/apps/web/lib/actions/request-password-reset.ts
+++ b/apps/web/lib/actions/request-password-reset.ts
@@ -14,7 +14,7 @@ import { actionClient } from "./safe-action";
// Request a password reset email
export const requestPasswordResetAction = actionClient
.schema(requestPasswordResetSchema, {
- handleValidationErrorsShape: (ve) =>
+ handleValidationErrorsShape: async (ve) =>
flattenValidationErrors(ve).fieldErrors,
})
.use(throwIfAuthenticated)
diff --git a/apps/web/lib/actions/send-otp.ts b/apps/web/lib/actions/send-otp.ts
index 17fb9a9af9..e9663d8341 100644
--- a/apps/web/lib/actions/send-otp.ts
+++ b/apps/web/lib/actions/send-otp.ts
@@ -23,7 +23,7 @@ const schema = z.object({
// Send OTP to email to verify account
export const sendOtpAction = actionClient
.schema(schema, {
- handleValidationErrorsShape: (ve) =>
+ handleValidationErrorsShape: async (ve) =>
flattenValidationErrors(ve).fieldErrors,
})
.use(throwIfAuthenticated)