port hubzillas OpenWebAuth - rename verify table to openwebauth-token
This commit is contained in:
parent
1ab3f7bfc8
commit
d5afbd3357
3 changed files with 12 additions and 12 deletions
|
@ -1085,9 +1085,9 @@ CREATE TABLE IF NOT EXISTS `user-item` (
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
|
) 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',
|
`id` int(10) NOT NULL auto_increment COMMENT 'sequential ID',
|
||||||
`uid` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
|
`uid` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
|
||||||
`type` varchar(32) DEFAULT '' COMMENT 'Verify type',
|
`type` varchar(32) DEFAULT '' COMMENT 'Verify type',
|
||||||
|
@ -1095,7 +1095,7 @@ CREATE TABLE IF NOT EXISTS `verify` (
|
||||||
`meta` varchar(255) DEFAULT '' COMMENT '',
|
`meta` varchar(255) DEFAULT '' COMMENT '',
|
||||||
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
|
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
|
||||||
PRIMARY KEY(`id`)
|
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
|
-- TABLE worker-ipc
|
||||||
|
|
|
@ -1818,8 +1818,8 @@ class DBStructure
|
||||||
"PRIMARY" => ["uid", "iid"],
|
"PRIMARY" => ["uid", "iid"],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$database["verify"] = [
|
$database["openwebauth-token"] = [
|
||||||
"comment" => "Store token to verify contacts",
|
"comment" => "Store OpenWebAuth token to verify contacts",
|
||||||
"fields" => [
|
"fields" => [
|
||||||
"id" => ["type" => "int(10)", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
|
"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"],
|
"uid" => ["type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
|
||||||
|
|
|
@ -10,12 +10,12 @@ use Friendica\Util\DateTimeFormat;
|
||||||
use dba;
|
use dba;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods to deal with entries of the 'verify' table.
|
* Methods to deal with entries of the 'openwebauth_token' table.
|
||||||
*/
|
*/
|
||||||
class Verify
|
class Verify
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create an entry in the 'verify' table.
|
* Create an entry in the 'openwebauth_token' table.
|
||||||
*
|
*
|
||||||
* @param string $type Verify type.
|
* @param string $type Verify type.
|
||||||
* @param int $uid The user ID.
|
* @param int $uid The user ID.
|
||||||
|
@ -33,11 +33,11 @@ class Verify
|
||||||
"meta" => $meta,
|
"meta" => $meta,
|
||||||
"created" => DateTimeFormat::utcNow()
|
"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 string $type Verify type.
|
||||||
* @param int $uid The user ID.
|
* @param int $uid The user ID.
|
||||||
|
@ -49,9 +49,9 @@ class Verify
|
||||||
{
|
{
|
||||||
$condition = ["type" => $type, "uid" => $uid, "token" => $token];
|
$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)) {
|
if (DBM::is_result($entry)) {
|
||||||
dba::delete("verify", ["id" => $entry["id"]]);
|
dba::delete("openwebauth_token", ["id" => $entry["id"]]);
|
||||||
|
|
||||||
return $entry["meta"];
|
return $entry["meta"];
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class Verify
|
||||||
public static function purge($type, $interval)
|
public static function purge($type, $interval)
|
||||||
{
|
{
|
||||||
$condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . " - INTERVAL " . $interval];
|
$condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . " - INTERVAL " . $interval];
|
||||||
dba::delete("verify", $condition);
|
dba::delete("openwebauth_token", $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue