Added guards for stash operations with missing arguments.

This commit is contained in:
2026-05-20 17:53:38 +02:00
parent 35ffc2b0f7
commit d463b3df5c

View File

@@ -200,6 +200,10 @@ export async function createStash(newStash, sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
if (!newStash) {
throw new HttpError('Missing new stash', 400);
}
verifyStashName(newStash);
try {
@@ -224,6 +228,14 @@ export async function updateStash(stashIdOrSlug, updatedStash, sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
if (!stashIdOrSlug) {
throw new HttpError('Missing stash ID or slug', 400);
}
if (!updatedStash) {
throw new HttpError('Missing updated stash', 400);
}
if (updatedStash.name) {
verifyStashName(updatedStash);
}
@@ -260,6 +272,10 @@ export async function removeStash(stashId, sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
if (!stashId) {
throw new HttpError('Missing stash ID', 400);
}
const stash = await fetchStashById(stashId, sessionUser);
if (!stash) {
@@ -283,6 +299,14 @@ export async function removeStash(stashId, sessionUser) {
}
export async function stashActor(actorId, stashId, sessionUser) {
if (!actorId) {
throw new HttpError('Missing actor ID', 400);
}
if (!stashId) {
throw new HttpError('Missing stash ID', 400);
}
const stash = await fetchStashById(stashId, sessionUser);
if (!stash) {
@@ -324,6 +348,14 @@ export async function stashActor(actorId, stashId, sessionUser) {
}
export async function unstashActor(actorId, stashId, sessionUser) {
if (!actorId) {
throw new HttpError('Missing actor ID', 400);
}
if (!stashId) {
throw new HttpError('Missing stash ID', 400);
}
const stash = await fetchStashById(stashId, sessionUser);
if (!stash) {
@@ -367,6 +399,14 @@ export async function unstashActor(actorId, stashId, sessionUser) {
}
export async function stashScene(sceneId, stashId, sessionUser) {
if (!sceneId) {
throw new HttpError('Missing scene ID', 400);
}
if (!stashId) {
throw new HttpError('Missing stash ID', 400);
}
const stash = await fetchStashById(stashId, sessionUser);
if (!stash) {
@@ -409,6 +449,14 @@ export async function stashScene(sceneId, stashId, sessionUser) {
}
export async function unstashScene(sceneId, stashId, sessionUser) {
if (!sceneId) {
throw new HttpError('Missing scene ID', 400);
}
if (!stashId) {
throw new HttpError('Missing stash ID', 400);
}
const stash = await fetchStashById(stashId, sessionUser);
if (!stash) {
@@ -448,6 +496,14 @@ export async function unstashScene(sceneId, stashId, sessionUser) {
}
export async function stashMovie(movieId, stashId, sessionUser) {
if (!movieId) {
throw new HttpError('Missing movie ID', 400);
}
if (!stashId) {
throw new HttpError('Missing stash ID', 400);
}
const stash = await fetchStashById(stashId, sessionUser);
if (!stash) {
@@ -489,6 +545,14 @@ export async function stashMovie(movieId, stashId, sessionUser) {
}
export async function unstashMovie(movieId, stashId, sessionUser) {
if (!movieId) {
throw new HttpError('Missing movie ID', 400);
}
if (!stashId) {
throw new HttpError('Missing stash ID', 400);
}
const stash = await fetchStashById(stashId, sessionUser);
if (!stash) {