diff --git a/db/schema.sql b/db/schema.sql index b8bea8221c..fc80693d35 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -767,7 +767,7 @@ create table token ( token varchar(255) not null, userid integer not null, type char not null, - create_time integer not null default unix_timestamp(), + create_time integer not null, expire_time integer, primary key (token), index token_userid (userid) diff --git a/html/inc/boinc_db.inc b/html/inc/boinc_db.inc index e37f45df8d..8a90bc1eb6 100644 --- a/html/inc/boinc_db.inc +++ b/html/inc/boinc_db.inc @@ -783,10 +783,11 @@ class BoincToken { return $db->lookup('token', 'BoincToken', $clause); } - static function lookup_valid_token($userid, $token) { + static function lookup_valid_token($userid, $token, $type) { $db = BoincDb::get(); $token = BoincDb::escape_string($token); - return self::lookup("userid=$userid and token='$token' and expire_time > unix_timestamp()"); + $type = BoincDb::escape_string($type); + return self::lookup("userid=$userid and token='$token' and expire_time > unix_timestamp() and type = '$type'"); } static function enum($where_clause) { diff --git a/html/ops/db_update.php b/html/ops/db_update.php index b622300175..cfcf107181 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -1080,7 +1080,7 @@ function update_4_5_2018() { token varchar(255) not null, userid integer not null, type char not null, - create_time integer not null default unix_timestamp(), + create_time integer not null, expire_time integer, primary key (token), index token_userid (userid) @@ -1096,6 +1096,12 @@ function update_4_6_2018() { "); } +function update_4_18_2018() { + do_query("alter table token + modify column create_time integer not null + "); +} + // Updates are done automatically if you use "upgrade". // // If you need to do updates manually, @@ -1151,6 +1157,7 @@ $db_updates = array ( array(27021, "update_3_8_2018"), array(27022, "update_4_5_2018"), array(27023, "update_4_6_2018"), + array(27024, "update_4_18_2018") ); ?>