Add API methods for supporting mobile APIs on other apps

V2_Rewrite
Skylar Ittner 7 years ago
parent 368a9c7e31
commit 766db4f3c4

@ -255,9 +255,18 @@ switch ($VARS['action']) {
$hasperm = account_has_permission($user, $perm); $hasperm = account_has_permission($user, $perm);
exit(json_encode(["status" => "OK", "has_permission" => $hasperm])); exit(json_encode(["status" => "OK", "has_permission" => $hasperm]));
break; 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: default:
http_response_code(404); 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) { /* } catch (Exception $e) {
header("HTTP/1.1 500 Internal Server Error"); header("HTTP/1.1 500 Internal Server Error");

Loading…
Cancel
Save