Add authentication and validation to delete-interest API, refactor modal list item
- Add x-tag header authentication check to delete-interest endpoint - Add ID validation and improved error handling with proper typing - Refactor InterestDetailsModal v-select item template structure
This commit is contained in:
parent
ef091d7b29
commit
94c5e3f140
|
|
@ -389,15 +389,18 @@
|
||||||
<template v-slot:item="{ item, props }">
|
<template v-slot:item="{ item, props }">
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-bind="props"
|
v-bind="props"
|
||||||
|
:title="item.value"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-icon :color="getSalesLevelColor(item.value)">
|
<v-icon :color="getSalesLevelColor(item.value)">
|
||||||
mdi-circle
|
mdi-circle
|
||||||
</v-icon>
|
</v-icon>
|
||||||
</template>
|
</template>
|
||||||
<v-list-item-title :style="{ color: getSalesLevelColor(item.value) }">
|
<template v-slot:title>
|
||||||
{{ item.value }}
|
<span :style="{ color: getSalesLevelColor(item.value) }">
|
||||||
</v-list-item-title>
|
{{ item.value }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
</v-select>
|
</v-select>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,20 @@
|
||||||
import { deleteInterest } from "~/server/utils/nocodb";
|
import { deleteInterest } from "~/server/utils/nocodb";
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const body = await readBody(event);
|
const xTagHeader = getRequestHeader(event, "x-tag");
|
||||||
const { id } = body;
|
|
||||||
const xTag = getHeader(event, "x-tag");
|
if (!xTagHeader || xTagHeader !== "094ut234") {
|
||||||
|
throw createError({ statusCode: 401, statusMessage: "unauthenticated" });
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const body = await readBody(event);
|
||||||
|
const { id } = body;
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: "ID is required" });
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the interest from NocoDB
|
// Delete the interest from NocoDB
|
||||||
await deleteInterest(id);
|
await deleteInterest(id);
|
||||||
|
|
||||||
|
|
@ -13,10 +22,14 @@ export default defineEventHandler(async (event) => {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Interest deleted successfully",
|
message: "Interest deleted successfully",
|
||||||
};
|
};
|
||||||
} catch (error: any) {
|
} catch (error) {
|
||||||
throw createError({
|
if (error instanceof Error) {
|
||||||
statusCode: 500,
|
throw createError({ statusCode: 500, statusMessage: error.message });
|
||||||
statusMessage: error.message || "Failed to delete interest",
|
} else {
|
||||||
});
|
throw createError({
|
||||||
|
statusCode: 500,
|
||||||
|
statusMessage: "An unexpected error occurred",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue