From 766db4f3c45f2e7ef7ad4401435d946ddcb90d0d Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Fri, 16 Jun 2017 22:25:26 -0600 Subject: [PATCH] Add API methods for supporting mobile APIs on other apps --- api.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api.php b/api.php index 0c40984..8e82bfc 100644 --- a/api.php +++ b/api.php @@ -255,9 +255,18 @@ switch ($VARS['action']) { $hasperm = account_has_permission($user, $perm); exit(json_encode(["status" => "OK", "has_permission" => $hasperm])); break; + case "mobileenabled": + exit(json_encode(["status" => "OK", "mobile" => MOBILE_ENABLED])); + case "mobilevalid": + if (is_empty($VARS['username']) || is_empty($VARS['code'])) { + http_response_code(400); + die("\"400 Bad Request\""); + } + $user_key_valid = $database->has('mobile_codes', ['[>]accounts' => ['uid' => 'uid']], ["AND" => ['mobile_codes.code' => $VARS['code'], 'accounts.username' => $VARS['username']]]); + exit(json_encode(["status" => "OK", "valid" => $user_key_valid])); default: http_response_code(404); - die(json_encode(["status" => "ERROR", "msg" => "The requested action is not available."])); + die(json_encode("404 Not Found: the requested action is not available.")); } /* } catch (Exception $e) { header("HTTP/1.1 500 Internal Server Error");