From bd12bdfe5637a6ee7d97a1174b15778a9f495933 Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Sat, 13 Aug 2011 21:07:51 +0200 Subject: Add validateuser.php ajax file returning json data saying whether a user exists and the credentials are correct --- core/ajax/validateuser.php | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 core/ajax/validateuser.php diff --git a/core/ajax/validateuser.php b/core/ajax/validateuser.php new file mode 100644 index 00000000000..967a5184a2c --- /dev/null +++ b/core/ajax/validateuser.php @@ -0,0 +1,57 @@ +. +* +*/ + +header("Content-Type: application/jsonrequest"); + +$RUNTIME_NOAPPS = TRUE; //no apps, yet + +require_once('../../lib/base.php'); + +$not_installed = !OC_Config::getValue('installed', false); + +// First step : check if the server is correctly configured for ownCloud : +$errors = OC_Util::checkServer(); +if(count($errors) > 0) { + echo json_encode(array("user_valid" => "false", "comment" => $errors)); +} + +// Setup required : +elseif($not_installed) { + echo json_encode(array("user_valid" => "false", "comment" => "not_installed")); + +} + +// Someone wants to check a user: +elseif(isset($_GET["user"]) and isset($_GET["password"])) { + if(OC_User::checkPassword($_GET["user"], $_GET["password"])) + echo json_encode(array("user_valid" => "true", "comment" => "")); + else + echo json_encode(array("user_valid" => "false", "comment" => "")); +} + +// For all others cases: +else { + echo json_encode(array("user_valid" => "false", "comment" => "unknown")); +} + +?> -- cgit v1.2.3