From d5afbd3357e00294b466be618d262a8e4c4e2ba9 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 20 Jun 2018 19:18:41 +0200 Subject: [PATCH] port hubzillas OpenWebAuth - rename verify table to openwebauth-token --- database.sql | 6 +++--- src/Database/DBStructure.php | 4 ++-- src/Model/Verify.php | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/database.sql b/database.sql index b871ce2de..d084ba519 100644 --- a/database.sql +++ b/database.sql @@ -1085,9 +1085,9 @@ CREATE TABLE IF NOT EXISTS `user-item` ( ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data'; -- --- TABLE verify +-- TABLE openwebauth-token -- -CREATE TABLE IF NOT EXISTS `verify` ( +CREATE TABLE IF NOT EXISTS `openwebauth-token` ( `id` int(10) NOT NULL auto_increment COMMENT 'sequential ID', `uid` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'User id', `type` varchar(32) DEFAULT '' COMMENT 'Verify type', @@ -1095,7 +1095,7 @@ CREATE TABLE IF NOT EXISTS `verify` ( `meta` varchar(255) DEFAULT '' COMMENT '', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation', PRIMARY KEY(`id`) -) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store token to verify contacts'; +) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts'; -- -- TABLE worker-ipc diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 33babded9..0d7ba49e4 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1818,8 +1818,8 @@ class DBStructure "PRIMARY" => ["uid", "iid"], ] ]; - $database["verify"] = [ - "comment" => "Store token to verify contacts", + $database["openwebauth-token"] = [ + "comment" => "Store OpenWebAuth token to verify contacts", "fields" => [ "id" => ["type" => "int(10)", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "uid" => ["type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], diff --git a/src/Model/Verify.php b/src/Model/Verify.php index 92dbafd3a..18fbb2eb5 100644 --- a/src/Model/Verify.php +++ b/src/Model/Verify.php @@ -10,12 +10,12 @@ use Friendica\Util\DateTimeFormat; use dba; /** - * Methods to deal with entries of the 'verify' table. + * Methods to deal with entries of the 'openwebauth_token' table. */ class Verify { /** - * Create an entry in the 'verify' table. + * Create an entry in the 'openwebauth_token' table. * * @param string $type Verify type. * @param int $uid The user ID. @@ -33,11 +33,11 @@ class Verify "meta" => $meta, "created" => DateTimeFormat::utcNow() ]; - return dba::insert("verify", $fields); + return dba::insert("openwebauth_token", $fields); } /** - * Get the "meta" field of an entry in the verify table. + * Get the "meta" field of an entry in the openwebauth_token table. * * @param string $type Verify type. * @param int $uid The user ID. @@ -49,9 +49,9 @@ class Verify { $condition = ["type" => $type, "uid" => $uid, "token" => $token]; - $entry = dba::selectFirst("verify", ["id", "meta"], $condition); + $entry = dba::selectFirst("openwebauth_token", ["id", "meta"], $condition); if (DBM::is_result($entry)) { - dba::delete("verify", ["id" => $entry["id"]]); + dba::delete("openwebauth_token", ["id" => $entry["id"]]); return $entry["meta"]; } @@ -67,7 +67,7 @@ class Verify public static function purge($type, $interval) { $condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . " - INTERVAL " . $interval]; - dba::delete("verify", $condition); + dba::delete("openwebauth_token", $condition); } }