From fca212a5425c1da1d8f5c26b9cf041025177688f Mon Sep 17 00:00:00 2001 From: osaajani Date: Wed, 19 Feb 2020 02:32:52 +0100 Subject: [PATCH] Add console function to create a user --- controllers/internals/Console.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/controllers/internals/Console.php b/controllers/internals/Console.php index 1f2c559..1970061 100755 --- a/controllers/internals/Console.php +++ b/controllers/internals/Console.php @@ -58,4 +58,21 @@ namespace controllers\internals; new \daemons\Phone($phone); } + + + /** + * Create a user + * @param $email : User email + * @param $password : User password + * @param $admin : Is user admin + * @param $api_key : User API key, if null random api key is generated + */ + public function create_user (string $email, string $password, bool $admin, ?string $api_key = null) + { + $bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, 'UTF8'); + $internal_user = new \controllers\internals\User($bdd); + + $success = $internal_user->create($email, $password, $admin, $api_key); + exit ((int) !$success); + } }