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/AddOrgMember.js
2022-12-17 16:37:51 -06:00

21 lines
577 B
JavaScript

const { Organization } = require('../../db/models/index');
const errors = require('../../config/error.json');
async function AddOrgMember(req, res, next) {
const user = req.user;
const orgID = req.params.orgID;
// Verify that an organization exists with the ID provided
const result = await Organization.findByPk(orgID);
if (!result) {
return res.status(404).send(errors.NotFound);
}
// Add the as a member to the found organization
await result.addMember(user.id);
return res.sendStatus(200);
}
module.exports = AddOrgMember;