diff --git a/core/user_logs/resources/classes/user_logs.php b/core/user_logs/resources/classes/user_logs.php index c1a1f0d461..b654a06416 100644 --- a/core/user_logs/resources/classes/user_logs.php +++ b/core/user_logs/resources/classes/user_logs.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2019 + Portions created by the Initial Developer are Copyright (C) 2019-2021 the Initial Developer. All Rights Reserved. Contributor(s): @@ -69,6 +69,42 @@ if (!class_exists('user_logs')) { } } + /** + * add user_logs + */ + public static function add($result) { + //prepare the array + $array['user_logs'][0]["timestamp"] = 'now()'; + $array['user_logs'][0]["domain_uuid"] = $result['domain_uuid']; + $array['user_logs'][0]["user_uuid"] = $result['user_uuid']; + $array['user_logs'][0]["username"] = $result['username']; + $array['user_logs'][0]["type"] = 'login'; + $array['user_logs'][0]["remote_address"] = $_SERVER['REMOTE_ADDR']; + $array['user_logs'][0]["user_agent"] = $_SERVER['HTTP_USER_AGENT']; + $array['user_logs'][0]["type"] = 'login'; + if ($result["authorized"] == "true") { + $array['user_logs'][0]["result"] = 'success'; + } + else { + $array['user_logs'][0]["result"] = 'failure'; + } + + //add the dialplan permission + $p = new permissions; + $p->add("user_log_add", 'temp'); + + //save to the data + $database = new database; + $database->app_name = 'authentication'; + $database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1'; + $database->uuid($user_log_uuid); + $database->save($array); + $message = $database->message; + + //remove the temporary permission + $p->delete("user_log_add", 'temp'); + } + /** * delete rows from the database */ @@ -122,4 +158,4 @@ if (!class_exists('user_logs')) { } } -?> \ No newline at end of file +?>