mirror of https://github.com/xfarrow/blink
update
This commit is contained in:
parent
aa8e67120f
commit
c164728a9b
|
@ -66,7 +66,7 @@ async function removeOrganizationAdmin(personId, organizationId) {
|
|||
// TODO: Understand whether a lock on the table is really necessary
|
||||
await transaction.raw('LOCK TABLE "OrganizationAdministrator" IN SHARE MODE');
|
||||
|
||||
await transaction('OrganizationAdministrator')
|
||||
const deletedAdmins = await transaction('OrganizationAdministrator')
|
||||
.where('id_person', personId)
|
||||
.where('id_organization', organizationId)
|
||||
.del();
|
||||
|
@ -83,8 +83,8 @@ async function removeOrganizationAdmin(personId, organizationId) {
|
|||
.where('id', organizationId)
|
||||
.del();
|
||||
}
|
||||
|
||||
await transaction.commit();
|
||||
return deletedAdmins === 1;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -64,8 +64,11 @@ async function removeOrganizationAdmin(req, res) {
|
|||
errors: errors.array()
|
||||
});
|
||||
}
|
||||
await organizationAdminModel.removeOrganizationAdmin(req.jwt.person_id, req.params.organizationId);
|
||||
return res.status(204).send();
|
||||
const success = await organizationAdminModel.removeOrganizationAdmin(req.jwt.person_id, req.params.organizationId);
|
||||
if(success){
|
||||
return res.status(204).send();
|
||||
}
|
||||
return res.status(404).send();
|
||||
} catch (error) {
|
||||
console.error(`Error in function ${removeOrganizationAdmin.name}: ${error}`);
|
||||
return res.status(500).json({
|
||||
|
|
Loading…
Reference in New Issue