]> git.wh0rd.org Git - tt-rss.git/commitdiff
api: forbid login when api is disabled
authorAndrew Dolgov <fox@bah.org.ru>
Wed, 16 Dec 2009 11:49:33 +0000 (14:49 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Wed, 16 Dec 2009 11:49:33 +0000 (14:49 +0300)
api/index.php

index 90ca5405c582cf6dbb0f0abb798433585cad610b..332e84f5a5d00dd5858512216721580cc03e9d11 100644 (file)
                        $login = db_escape_string($_REQUEST["user"]);
                        $password = db_escape_string($_REQUEST["password"]);
 
-                       if (authenticate_user($link, $login, $password)) {
-                               print json_encode(array("uid" => $_SESSION["uid"]));
+                       if (get_pref($link, "ENABLE_API_ACCESS", $login)) {
+                               if (authenticate_user($link, $login, $password)) {
+                                       print json_encode(array("uid" => $_SESSION["uid"]));
+                               } else {
+                                       print json_encode(array("error" => "LOGIN_ERROR"));
+                               }
                        } else {
-                               print json_encode(array("error" => "LOGIN_ERROR"));
+                               logout_user();
+                               print json_encode(array("error" => "API_DISABLED"));
                        }
 
                        break;