From 6b123765b6a0f9ae2a9a08c0b912524d93024894 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 7 Nov 2017 12:16:13 +0100 Subject: [PATCH] Added module 'authenticationDefault/get_admins' to fetch all admins of the warehouse --- build/api/module/authenticationDefault.php | 23 ++++++++++++++++++++++ config/modules.json | 9 +++++++++ config/repositories.json | 1 + 3 files changed, 33 insertions(+) diff --git a/build/api/module/authenticationDefault.php b/build/api/module/authenticationDefault.php index 9b58064..c9d4435 100755 --- a/build/api/module/authenticationDefault.php +++ b/build/api/module/authenticationDefault.php @@ -122,7 +122,30 @@ + /* RETOURNE LA LISTE DSE ADMINISTRATEURS DE L'ENTREPOT + * + * @return admins Liste des administrateurs de l'entrepôt + * + */ + public function get_admins($params){ + /* (1) Fetch admin list + ---------------------------------------------------------*/ + /* (1) Prepare request */ + $listRq = new Repo('admin/getByIdWarehouse', [ $_SESSION['WAREHOUSE']['id'] ]); + /* (2) Get response */ + $listRs = $listRq->answer(); + + /* (3) Manage error */ + if( !is_array($listRs) ) + return ['error' => new Error(Err::RepoError)]; + + + /* (2) Setup data (remove self) + ---------------------------------------------------------*/ + return ['admins' => $listRs]; + + } diff --git a/config/modules.json b/config/modules.json index aa72320..d7f9f89 100755 --- a/config/modules.json +++ b/config/modules.json @@ -61,6 +61,15 @@ } }, + "POST::get_admins": { + "description": "Retourne la liste des administrateurs de l'entrepôt.", + "permissions": [["admin"]], + "parameters": {}, + "output": { + "admin": { "description": "Liste des administrateur.", "type": "array" } + } + }, + "POST::update_admin": { "description": "Changement de mot de passe administrateur", "permissions": [["admin"]], diff --git a/config/repositories.json b/config/repositories.json index 3a13be1..3b66f9d 100755 --- a/config/repositories.json +++ b/config/repositories.json @@ -160,6 +160,7 @@ "getAll", "getById", "getByUsername", + "getByIdWarehouse", "getByMail", "getByToken",