mirror of
				https://github.com/xfarrow/blink
				synced 2025-06-27 09:03:02 +02:00 
			
		
		
		
	Update api_controller.js
This commit is contained in:
		| @@ -277,9 +277,8 @@ async function addOrganizationAdmin(req, res){ | |||||||
|     return res.status(400).json({ error : "Invalid request"}); |     return res.status(400).json({ error : "Invalid request"}); | ||||||
|   }   |   }   | ||||||
|  |  | ||||||
|   // Check whether I am admin and if I'm not trying to make myself admin |   // Check whether I am admin | ||||||
|   if(await isPersonOrganizationAdmin(req.jwt.person_id, req.body.organization_id)  |   if(await isPersonOrganizationAdmin(req.jwt.person_id, req.body.organization_id)){ | ||||||
|   && req.jwt.person_id != req.body.person_id){ |  | ||||||
|     try { |     try { | ||||||
|       // We suppose that the database has Foreign Key constraints |       // We suppose that the database has Foreign Key constraints | ||||||
|       await knex('OrganizationAdministrator') |       await knex('OrganizationAdministrator') | ||||||
| @@ -291,10 +290,6 @@ async function addOrganizationAdmin(req, res){ | |||||||
|     }  |     }  | ||||||
|     catch (error) { |     catch (error) { | ||||||
|       console.error('Error while adding organization admin: ' + error); |       console.error('Error while adding organization admin: ' + error); | ||||||
|       // Foreign Key Constraint Violation |  | ||||||
|       if (error.code === '23503') { |  | ||||||
|         return res.status(404).json({ error : "Not found"}); |  | ||||||
|       } |  | ||||||
|       res.status(500).json({error : "Internal server error"}); |       res.status(500).json({error : "Internal server error"}); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user