Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Delete Job, update user status bug #1

Open
b30wulffz opened this issue Feb 28, 2021 · 2 comments · May be fixed by #12
Open

Fix Delete Job, update user status bug #1

b30wulffz opened this issue Feb 28, 2021 · 2 comments · May be fixed by #12

Comments

@b30wulffz
Copy link
Owner

Ideally, If a person is selected for a job, and his job is deleted by the recruiter, then his job status should be updated and he should become free to apply for another jobs.

Currently, in the code, this is not handled, and hence needs to be fixed.

@rohity20
Copy link

rohity20 commented Sep 28, 2023

The given API route deletes a job if the user is a recruiter, updates related applications, and returns appropriate HTTP responses for authorization and errors.

router.delete("/jobs/:id", jwtAuth, async (req, res) => {
try {
const user = req.user;

if (user.type !== "recruiter") {
  return res.status(401).json({
    message: "You don't have permissions to delete the job",
  });
}

const job = await Job.findOneAndDelete({
  _id: req.params.id,
  userId: user.id,
});

if (job === null) {
  return res.status(401).json({
    message: "You don't have permissions to delete the job",
  });
}

// Updating status of applications of the job (applied to deleted)
const applications = await Application.updateMany
(
  { jobId: job._id },
  { status: "deleted" }
);

res.json({
  message: "Job deleted successfully",
});

} catch (err) {
res.status(400).json(err);
}
});

@rohity20 rohity20 linked a pull request Oct 1, 2023 that will close this issue
@muskank101
Copy link

I need help https://www.linkedin.com/in/muskan-koshti-829072237/
let's connect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants