Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Stop sending established accounts to setup over datetime fields (#2771)

Luke Vellaa213e9072351
diff --git a/apps/web/src/app/[locale]/setup/page.tsx b/apps/web/src/app/[locale]/setup/page.tsx
index de26612c5..1a9e91df2 100644
--- a/apps/web/src/app/[locale]/setup/page.tsx
+++ b/apps/web/src/app/[locale]/setup/page.tsx
@@ -23,7 +23,10 @@ export default async function SetupPage(props: {
// and had them create a second space.
const space = await getOwnedSpace(user.id);
- if (user.name && user.timeZone && user.timeFormat && space) {
+ // Mirrors the gate in features/space/loaders.ts: name and a space are
+ // required, timezone and time format are not. The two conditions have to
+ // agree or the user ping-pongs between here and the app.
+ if (user.name && space) {
redirect(validateRedirectUrl(searchParams?.redirectTo) ?? "/");
}
diff --git a/apps/web/src/features/space/loaders.test.ts b/apps/web/src/features/space/loaders.test.ts
index e5224b50a..3ff0451b2 100644
--- a/apps/web/src/features/space/loaders.test.ts
+++ b/apps/web/src/features/space/loaders.test.ts
@@ -105,8 +105,8 @@ describe("getActiveSpace", () => {
expect(mockRedirect).not.toHaveBeenCalled();
});
- it("redirects to /setup when profile fields are missing, before reading spaces", async () => {
- authenticatedAs({ ...completeUser, timeFormat: undefined });
+ it("redirects to /setup when the name is missing, before reading spaces", async () => {
+ authenticatedAs({ ...completeUser, name: "" });
const gate = await loadGate();
@@ -117,6 +117,23 @@ describe("getActiveSpace", () => {
expect(mockGetActiveSpaceForUser).not.toHaveBeenCalled();
});
+ // Long-standing accounts predate the timeZone/timeFormat columns. Both
+ // resolve without a stored value, so a null must not force onboarding.
+ it.each([
+ ["timeZone", { timeZone: undefined }],
+ ["timeFormat", { timeFormat: undefined }],
+ ["both", { timeZone: undefined, timeFormat: undefined }],
+ ])("does not redirect to /setup when %s is missing", async (_label, patch) => {
+ const space = { id: "space-1", name: "Personal" };
+ authenticatedAs({ ...completeUser, ...patch });
+ mockGetActiveSpaceForUser.mockResolvedValue(space);
+
+ const gate = await loadGate();
+
+ await expect(gate()).resolves.toEqual(space);
+ expect(mockRedirect).not.toHaveBeenCalled();
+ });
+
it("redirects to /login for a guest", async () => {
authenticatedAs({ ...completeUser, isGuest: true });
diff --git a/apps/web/src/features/space/loaders.ts b/apps/web/src/features/space/loaders.ts
index 53ab81092..5a072624d 100644
--- a/apps/web/src/features/space/loaders.ts
+++ b/apps/web/src/features/space/loaders.ts
@@ -51,10 +51,12 @@ export const getActiveSpace = cache(async () => {
}
// Accounts created through the OTP registration flow start without a
- // name, timezone, or time format; /setup collects them before they can
- // use the app. Pre-existing accounts missing any of these go through
- // the same (prefilled) form once.
- if (!user.name || !user.timeZone || !user.timeFormat) {
+ // name; /setup collects one before they can use the app. Timezone and
+ // time format are deliberately NOT gated on: both resolve without a
+ // stored value (zone from the per-visit cookie, format from
+ // getLocaleDefaults), and gating on them dragged long-standing accounts
+ // that predate those columns back through onboarding.
+ if (!user.name) {
redirect(
buildSafeRedirectUrl({
destination: "/setup",