POST api.module.admin (added create) | upgraded autoloader.php
This commit is contained in:
parent
5cdc2f9945
commit
a4ba4fdc9a
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
/* [0] On definit la racine __BUILD__ si c'est pas deja fait
|
||||
/* [1] On definit les chemins absolus si c'est pas deja fait
|
||||
=========================================================*/
|
||||
if( !defined('__ROOT__') ) define('__ROOT__', dirname(__FILE__) );
|
||||
if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' );
|
||||
|
@ -8,8 +8,6 @@
|
|||
if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' );
|
||||
|
||||
|
||||
|
||||
|
||||
/* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION)
|
||||
*
|
||||
*/
|
||||
|
@ -21,6 +19,18 @@
|
|||
|
||||
|
||||
|
||||
/* Secure Hash Function
|
||||
*
|
||||
* @raw<String> Data to hash
|
||||
* @salt<String> Salt to use for hashing
|
||||
* @pepper<String> Pepper to use for hashing
|
||||
*
|
||||
*/
|
||||
function secure_hash(String $raw, String $salt='2104\'dsa:">AS"D:', String $pepper='3894.234123;\'21'){
|
||||
return hash('sha512', $pepper.hash('sha512', $raw.$salt));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* AUTOLOADER
|
||||
*
|
||||
|
@ -46,6 +56,4 @@
|
|||
spl_autoload_register('autoloader', false, true);
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace api\module;
|
||||
|
||||
use \error\core\Error;
|
||||
use \error\core\Err;
|
||||
use \database\core\Repo;
|
||||
|
||||
|
||||
|
@ -38,6 +39,33 @@
|
|||
---------------------------------------------------------*/
|
||||
}else
|
||||
return [ 'data' => Repo::request('admin', 'getAll') ];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (2) Creates a new administrator
|
||||
*
|
||||
* @username<string> Identifiant de l'administrateur
|
||||
* @mail<string> Adresse mail de l'administrateur
|
||||
* @password<string> Mot de passe de l'administrateur
|
||||
*
|
||||
* @return id_admin<id> UID de l'administrateur crée
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function post($args){
|
||||
extract($args);
|
||||
|
||||
/* (1) Création admin */
|
||||
$id_created = Repo::request('admin', 'create', $username, $mail, $password);
|
||||
|
||||
/* (2) Gestion erreur */
|
||||
if( $id_created === false )
|
||||
return [ 'error' => new Error(Err::RepoError) ];
|
||||
|
||||
/* (3) Renvoi @id_admin */
|
||||
return [ 'id_admin' => $id_created ];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue