Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: guard mobile download access

Richie McIlroy45e528f7bcc2
diff --git a/apps/web/app/(org)/login/form.tsx b/apps/web/app/(org)/login/form.tsx
index b8b4328a6..2a41d94f6 100644
--- a/apps/web/app/(org)/login/form.tsx
+++ b/apps/web/app/(org)/login/form.tsx
@@ -51,12 +51,20 @@ export function LoginForm() {
);
const mobileGoogleSignInStarted = useRef(false);
const mobileWorkosSignInStarted = useRef(false);
+ const loginFormMounted = useRef(false);
const theme = Cookies.get("theme") || "light";
const getNextPath = useCallback(
() => (next ? getSafeNextPath(next, window.location.origin) : null),
[next],
);
+ useEffect(() => {
+ loginFormMounted.current = true;
+ return () => {
+ loginFormMounted.current = false;
+ };
+ }, []);
+
useEffect(() => {
document.body.className = theme === "dark" ? "dark" : "light";
return () => {
@@ -162,6 +170,7 @@ export function LoginForm() {
mobileWorkosSignInStarted.current = true;
handleWorkosSignIn(mobileOrganizationId).catch(() => {
+ if (!loginFormMounted.current) return;
setOrganizationId(mobileOrganizationId);
setShowOrgInput(true);
toast.error("Organization not found or SSO not configured");
diff --git a/apps/web/app/api/mobile/[...route]/route.ts b/apps/web/app/api/mobile/[...route]/route.ts
index 719a9216d..20a7829c8 100644
--- a/apps/web/app/api/mobile/[...route]/route.ts
+++ b/apps/web/app/api/mobile/[...route]/route.ts
@@ -1301,18 +1301,21 @@ const ApiLive = HttpApiBuilder.api(Mobile.MobileApiContract).pipe(
)
.handle("getDownload", ({ path }) =>
withMappedErrors(
- videos.getDownloadInfo(path.id).pipe(
- Effect.flatMap(
- Option.match({
- onNone: () => Effect.fail(new HttpApiError.NotFound()),
- onSome: (info) =>
- Effect.succeed({
- fileName: info.fileName,
- url: info.downloadUrl,
- }),
- }),
- ),
- ),
+ Effect.gen(function* () {
+ yield* getCapById(path.id);
+ return yield* videos.getDownloadInfo(path.id).pipe(
+ Effect.flatMap(
+ Option.match({
+ onNone: () => Effect.fail(new HttpApiError.NotFound()),
+ onSome: (info) =>
+ Effect.succeed({
+ fileName: info.fileName,
+ url: info.downloadUrl,
+ }),
+ }),
+ ),
+ );
+ }),
),
)
.handle("createComment", ({ path, payload }) =>