Tweak mobile APIs

V2_Rewrite
Skylar Ittner 7 years ago
parent b95397f420
commit bee707be8a

@ -31,7 +31,7 @@ if ($_GET['mobilecode'] == "generate") {
$code = strtoupper(substr(md5(mt_rand() . uniqid("", true)), 0, 20)); $code = strtoupper(substr(md5(mt_rand() . uniqid("", true)), 0, 20));
$database->insert('mobile_codes', ['uid' => $_SESSION['uid'], 'code' => $code]); $database->insert('mobile_codes', ['uid' => $_SESSION['uid'], 'code' => $code]);
} }
$url = str_replace("/", "\\", URL); $url = str_replace("/", "\\", URL . "mobile/index.php");
$codeuri = "bizsync://" . $url . "/" . $_SESSION['username'] . "/" . $code; $codeuri = "bizsync://" . $url . "/" . $_SESSION['username'] . "/" . $code;
$qrCode = new QrCode($codeuri); $qrCode = new QrCode($codeuri);
$qrCode->setSize(200); $qrCode->setSize(200);

Binary file not shown.

@ -9,6 +9,7 @@ require __DIR__ . "/../required.php";
require __DIR__ . "/../lib/login.php"; require __DIR__ . "/../lib/login.php";
header('Content-Type: application/json'); header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
// Allow ping check without authentication // Allow ping check without authentication
if ($VARS['action'] == "ping") { if ($VARS['action'] == "ping") {
@ -60,6 +61,25 @@ switch ($VARS['action']) {
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)])); exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
} }
} }
case "user_info":
engageRateLimit();
if (get_account_status($VARS['username']) != "NORMAL") {
insertAuthLog(20, null, "Username: " . $VARS['username'] . ", Key: " . $VARS['key']);
exit(json_encode(["status" => "ERROR", "msg" => lang("login failed try on web", false)]));
}
if (authenticate_user($VARS['username'], $VARS['password'], $autherror)) {
$userinfo = $database->get("accounts", ["uid", "username", "realname", "email"], ["username" => $VARS['username']]);
insertAuthLog(19, $userinfo['uid'], "Key: " . $VARS['key']);
exit(json_encode(["status" => "OK", "info" => $userinfo]));
} else {
if (!is_empty($autherror)) {
insertAuthLog(20, null, "Username: " . $VARS['username'] . ", Key: " . $VARS['key']);
exit(json_encode(["status" => "ERROR", "msg" => $autherror]));
} else {
insertAuthLog(20, null, "Username: " . $VARS['username'] . ", Key: " . $VARS['key']);
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
}
}
case "start_session": case "start_session":
// Do a web login. // Do a web login.
engageRateLimit(); engageRateLimit();
@ -72,6 +92,8 @@ switch ($VARS['action']) {
} }
} }
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)])); exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
case "listapps":
exit(json_encode(["status" => "OK", "apps" => EXTERNAL_APPS]));
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(["status" => "ERROR", "msg" => "The requested action is not available."]));

@ -73,25 +73,25 @@ define('LANGUAGE', "en_us");
define('EXTERNAL_APPS', [ define('EXTERNAL_APPS', [
"portal" => [ "portal" => [
"url" => "http://localhost/portal", "url" => "http://localhost/portal",
"mobileapi" => "/mobile", "mobileapi" => "/mobile/index.php",
"icon" => "/static/img/logo.svg", "icon" => "/static/img/logo.svg",
"title" => SITE_TITLE "title" => SITE_TITLE
], ],
"taskfloor" => [ "taskfloor" => [
"url" => "http://localhost/taskfloor", "url" => "http://localhost/taskfloor",
"mobileapi" => "/mobile", "mobileapi" => "/mobile/index.php",
"icon" => "/static/img/logo.svg", "icon" => "/static/img/logo.svg",
"title" => "TaskFloor" "title" => "TaskFloor"
], ],
"qwikclock" => [ "qwikclock" => [
"url" => "http://localhost/qwikclock", "url" => "http://localhost/qwikclock",
"mobileapi" => "/mobile", "mobileapi" => "/mobile/index.php",
"icon" => "/static/img/logo.svg", "icon" => "/static/img/logo.svg",
"title" => "QwikClock" "title" => "QwikClock"
], ],
"inventory" => [ "inventory" => [
"url" => "http://localhost/inventory", "url" => "http://localhost/inventory",
"mobileapi" => "/mobile", "mobileapi" => "/mobile/index.php",
"icon" => "/static/img/logo.svg", "icon" => "/static/img/logo.svg",
"title" => "Inventory" "title" => "Inventory"
] ]

Loading…
Cancel
Save