mirror of
https://github.com/xfarrow/blink
synced 2025-04-23 18:17:22 +02:00
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
|
// TODO: Understand whether a lock on the table is really necessary
|
||||||
await transaction.raw('LOCK TABLE "OrganizationAdministrator" IN SHARE MODE');
|
await transaction.raw('LOCK TABLE "OrganizationAdministrator" IN SHARE MODE');
|
||||||
|
|
||||||
await transaction('OrganizationAdministrator')
|
const deletedAdmins = await transaction('OrganizationAdministrator')
|
||||||
.where('id_person', personId)
|
.where('id_person', personId)
|
||||||
.where('id_organization', organizationId)
|
.where('id_organization', organizationId)
|
||||||
.del();
|
.del();
|
||||||
@ -83,8 +83,8 @@ async function removeOrganizationAdmin(personId, organizationId) {
|
|||||||
.where('id', organizationId)
|
.where('id', organizationId)
|
||||||
.del();
|
.del();
|
||||||
}
|
}
|
||||||
|
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
|
return deletedAdmins === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -64,8 +64,11 @@ async function removeOrganizationAdmin(req, res) {
|
|||||||
errors: errors.array()
|
errors: errors.array()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await organizationAdminModel.removeOrganizationAdmin(req.jwt.person_id, req.params.organizationId);
|
const success = await organizationAdminModel.removeOrganizationAdmin(req.jwt.person_id, req.params.organizationId);
|
||||||
|
if(success){
|
||||||
return res.status(204).send();
|
return res.status(204).send();
|
||||||
|
}
|
||||||
|
return res.status(404).send();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error in function ${removeOrganizationAdmin.name}: ${error}`);
|
console.error(`Error in function ${removeOrganizationAdmin.name}: ${error}`);
|
||||||
return res.status(500).json({
|
return res.status(500).json({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user