add per-user option to enable access to API

This commit is contained in:
Andrew Dolgov 2009-12-16 14:36:59 +03:00
parent f5a5bae463
commit 3a216db45c
7 changed files with 25 additions and 7 deletions

View file

@ -44,11 +44,10 @@
return; return;
} }
/* TODO: add pref key to disable/enable API if ($_SESSION["uid"] && $op != "logout" && !get_pref($link, 'ENABLE_API_ACCESS')) {
if ($_SESSION["uid"] && !get_pref($link, 'API_ENABLED')) {
print json_encode(array("error" => 'API_DISABLED')); print json_encode(array("error" => 'API_DISABLED'));
return; return;
} */ }
switch ($op) { switch ($op) {
case "getVersion": case "getVersion":
@ -62,7 +61,7 @@
if (authenticate_user($link, $login, $password)) { if (authenticate_user($link, $login, $password)) {
print json_encode(array("uid" => $_SESSION["uid"])); print json_encode(array("uid" => $_SESSION["uid"]));
} else { } else {
print json_encode(array("uid" => 0)); print json_encode(array("error" => "LOGIN_ERROR"));
} }
break; break;

View file

@ -81,5 +81,6 @@
__("Enable inline MP3 player"); __("Enable inline MP3 player");
__("Enable the Flash-based XSPF Player to play MP3-format podcast enclosures."); __("Enable the Flash-based XSPF Player to play MP3-format podcast enclosures.");
__("Do not show images in articles"); __("Do not show images in articles");
__("Enable external API");
?> ?>

View file

@ -2,7 +2,7 @@
require_once "functions.php"; require_once "functions.php";
define('EXPECTED_CONFIG_VERSION', 18); define('EXPECTED_CONFIG_VERSION', 18);
define('SCHEMA_VERSION', 57); define('SCHEMA_VERSION', 58);
if (!file_exists("config.php")) { if (!file_exists("config.php")) {
print "<b>Fatal Error</b>: You forgot to copy print "<b>Fatal Error</b>: You forgot to copy

View file

@ -226,7 +226,7 @@ create table ttrss_tags (id integer primary key auto_increment,
create table ttrss_version (schema_version int not null) TYPE=InnoDB; create table ttrss_version (schema_version int not null) TYPE=InnoDB;
insert into ttrss_version values (57); insert into ttrss_version values (58);
create table ttrss_enclosures (id serial not null primary key, create table ttrss_enclosures (id serial not null primary key,
content_url text not null, content_url text not null,
@ -359,6 +359,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_OFFLINE_READING', 1, 'false', 'Enable offline reading',1, 'Synchronize new articles for offline reading using Google Gears.'); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_OFFLINE_READING', 1, 'false', 'Enable offline reading',1, 'Synchronize new articles for offline reading using Google Gears.');
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_API_ACCESS', 1, 'false', 'Enable external API', 3);
create table ttrss_user_prefs ( create table ttrss_user_prefs (
owner_uid integer not null, owner_uid integer not null,
pref_name varchar(250), pref_name varchar(250),

View file

@ -202,7 +202,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
create table ttrss_version (schema_version int not null); create table ttrss_version (schema_version int not null);
insert into ttrss_version values (57); insert into ttrss_version values (58);
create table ttrss_enclosures (id serial not null primary key, create table ttrss_enclosures (id serial not null primary key,
content_url text not null, content_url text not null,
@ -329,6 +329,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_OFFLINE_READING', 1, 'false', 'Enable offline reading',1, 'Synchronize new articles for offline reading using Google Gears.'); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_OFFLINE_READING', 1, 'false', 'Enable offline reading',1, 'Synchronize new articles for offline reading using Google Gears.');
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_API_ACCESS', 1, 'false', 'Enable external API', 3);
create table ttrss_user_prefs ( create table ttrss_user_prefs (
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE, owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE, pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,

View file

@ -0,0 +1,7 @@
begin;
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_API_ACCESS', 1, 'false', 'Enable external API', 3);
update ttrss_version set schema_version = 58;
commit;

View file

@ -0,0 +1,7 @@
begin;
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_API_ACCESS', 1, 'false', 'Enable external API', 3);
update ttrss_version set schema_version = 58;
commit;