Skip to content

Commit

Permalink
feat: check auth before shareable link creation
Browse files Browse the repository at this point in the history
  • Loading branch information
richiemcilroy committed Jan 17, 2025
1 parent 82a1db0 commit 2ac1c75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/desktop/src/routes/editor/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { getCurrentWindow, ProgressBarStatus } from "@tauri-apps/api/window";

import { type RenderProgress, commands, events } from "~/utils/tauri";
import { FPS, useEditorContext } from "./context";
import { authStore } from "~/store";
import {
Dialog,
DialogContent,
Expand Down Expand Up @@ -585,6 +586,14 @@ function ShareButton(props: ShareButtonProps) {
const uploadVideo = createMutation(() => ({
mutationFn: async (useCustomMuxer: boolean) => {
console.log("Starting upload process...");

// Check authentication first
const existingAuth = await authStore.get();
if (!existingAuth) {
await commands.showWindow("SignIn");
throw new Error("You need to sign in to share recordings");
}

const meta = recordingMeta();
if (!meta) {
console.error("No recording metadata available");
Expand Down Expand Up @@ -709,6 +718,7 @@ function ShareButton(props: ShareButtonProps) {
});

if (result === "NotAuthenticated") {
await commands.showWindow("SignIn");
throw new Error("You need to sign in to share recordings");
}
if (result === "PlanCheckFailed") {
Expand Down
8 changes: 8 additions & 0 deletions apps/desktop/src/routes/recordings-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { DEFAULT_PROJECT_CONFIG } from "./editor/projectConfig";
import { createPresets } from "~/utils/createPresets";
import { progressState, setProgressState } from "~/store/progress";
import { FPS, OUTPUT_SIZE } from "./editor/context";
import { authStore } from "~/store";

type MediaEntry = {
path: string;
Expand Down Expand Up @@ -983,6 +984,13 @@ function createRecordingMutations(
return;
}

// Check authentication first
const existingAuth = await authStore.get();
if (!existingAuth) {
await commands.showWindow("SignIn");
throw new Error("You need to sign in to share recordings");
}

const metadata = await commands.getVideoMetadata(media.path, null);
const plan = await commands.checkUpgradedAndUpdate();
const canShare = {
Expand Down

1 comment on commit 2ac1c75

@vercel
Copy link

@vercel vercel bot commented on 2ac1c75 Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.