mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 03:32:22 +08:00
Merge pull request #374 from StefanTerdell/fix-372
Only check Supabase if configured to when cancelling job
This commit is contained in:
commit
002bfdf639
|
@ -8,6 +8,8 @@ import { billTeam } from "../../src/services/billing/credit_billing";
|
||||||
|
|
||||||
export async function crawlCancelController(req: Request, res: Response) {
|
export async function crawlCancelController(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
|
const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';
|
||||||
|
|
||||||
const { success, team_id, error, status } = await authenticateUser(
|
const { success, team_id, error, status } = await authenticateUser(
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
|
@ -22,18 +24,21 @@ export async function crawlCancelController(req: Request, res: Response) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the job belongs to the team
|
// check if the job belongs to the team
|
||||||
const { data, error: supaError } = await supabase_service
|
if (useDbAuthentication) {
|
||||||
.from("bulljobs_teams")
|
const { data, error: supaError } = await supabase_service
|
||||||
.select("*")
|
.from("bulljobs_teams")
|
||||||
.eq("job_id", req.params.jobId)
|
.select("*")
|
||||||
.eq("team_id", team_id);
|
.eq("job_id", req.params.jobId)
|
||||||
if (supaError) {
|
.eq("team_id", team_id);
|
||||||
return res.status(500).json({ error: supaError.message });
|
if (supaError) {
|
||||||
|
return res.status(500).json({ error: supaError.message });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.length === 0) {
|
||||||
|
return res.status(403).json({ error: "Unauthorized" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.length === 0) {
|
|
||||||
return res.status(403).json({ error: "Unauthorized" });
|
|
||||||
}
|
|
||||||
const jobState = await job.getState();
|
const jobState = await job.getState();
|
||||||
const { partialDocs } = await job.progress();
|
const { partialDocs } = await job.progress();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user