This repository has been archived on 2025-11-04. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
know-it-all/server/routes/org/DeleteOrg.js

20 lines
524 B
JavaScript

const { Organization } = require('../../db/models/index');
async function DeleteOrg(req, res, next) {
const user = req.user;
const orgID = req.query.orgID;
// Error if an organization id was not provided
if (!orgID) {
return res.status(400).send('Form missing required fields');
}
// Destroy all organizations with that ID
await Organization.destroy({
where: { id: orgID, ownerID: user.id },
});
return res.send('Organization deleted');
}
module.exports = DeleteOrg;