--- /dev/null
+<?php
+
+/**
+ * @file src/Model/OpenWebAuthToken.php
+ */
+namespace Friendica\Model;
+
+use Friendica\Database\DBM;
+use Friendica\Util\DateTimeFormat;
+use dba;
+
+/**
+ * Methods to deal with entries of the 'openwebauth_token' table.
+ */
+class OpenWebAuthToken
+{
+ /**
+ * Create an entry in the 'openwebauth_token' table.
+ *
+ * @param string $type Verify type.
+ * @param int $uid The user ID.
+ * @param string $token
+ * @param string $meta
+ *
+ * @return boolean
+ */
+ public static function create($type, $uid, $token, $meta)
+ {
+ $fields = [
+ "type" => $type,
+ "uid" => $uid,
+ "token" => $token,
+ "meta" => $meta,
+ "created" => DateTimeFormat::utcNow()
+ ];
+ return dba::insert("openwebauth_token", $fields);
+ }
+
+ /**
+ * Get the "meta" field of an entry in the openwebauth_token table.
+ *
+ * @param string $type Verify type.
+ * @param int $uid The user ID.
+ * @param string $token
+ *
+ * @return string|boolean The meta enry or false if not found.
+ */
+ public static function getMeta($type, $uid, $token)
+ {
+ $condition = ["type" => $type, "uid" => $uid, "token" => $token];
+
+ $entry = dba::selectFirst("openwebauth_token", ["id", "meta"], $condition);
+ if (DBM::is_result($entry)) {
+ dba::delete("openwebauth_token", ["id" => $entry["id"]]);
+
+ return $entry["meta"];
+ }
+ return false;
+ }
+
+ /**
+ * Purge entries of a verify-type older than interval.
+ *
+ * @param string $type Verify type.
+ * @param string $interval SQL compatible time interval
+ */
+ public static function purge($type, $interval)
+ {
+ $condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . " - INTERVAL " . $interval];
+ dba::delete("openwebauth_token", $condition);
+ }
+
+}
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
-use Friendica\Model\Verify;
+use Friendica\Model\OpenWebAuthToken;
use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
{
$a = get_app();
- // Clean old verify entries.
- Verify::purge('owt', '3 MINUTE');
+ // Clean old OpenWebAuthToken entries.
+ OpenWebAuthToken::purge('owt', '3 MINUTE');
// Check if the token we got is the same one
// we have stored in the database.
- $visitor_handle = Verify::getMeta('owt', 0, $token);
+ $visitor_handle = OpenWebAuthToken::getMeta('owt', 0, $token);
if($visitor_handle === false) {
return;
+++ /dev/null
-<?php
-
-/**
- * @file src/Model/Verify.php
- */
-namespace Friendica\Model;
-
-use Friendica\Database\DBM;
-use Friendica\Util\DateTimeFormat;
-use dba;
-
-/**
- * Methods to deal with entries of the 'openwebauth_token' table.
- */
-class Verify
-{
- /**
- * Create an entry in the 'openwebauth_token' table.
- *
- * @param string $type Verify type.
- * @param int $uid The user ID.
- * @param string $token
- * @param string $meta
- *
- * @return boolean
- */
- public static function create($type, $uid, $token, $meta)
- {
- $fields = [
- "type" => $type,
- "uid" => $uid,
- "token" => $token,
- "meta" => $meta,
- "created" => DateTimeFormat::utcNow()
- ];
- return dba::insert("openwebauth_token", $fields);
- }
-
- /**
- * Get the "meta" field of an entry in the openwebauth_token table.
- *
- * @param string $type Verify type.
- * @param int $uid The user ID.
- * @param string $token
- *
- * @return string|boolean The meta enry or false if not found.
- */
- public static function getMeta($type, $uid, $token)
- {
- $condition = ["type" => $type, "uid" => $uid, "token" => $token];
-
- $entry = dba::selectFirst("openwebauth_token", ["id", "meta"], $condition);
- if (DBM::is_result($entry)) {
- dba::delete("openwebauth_token", ["id" => $entry["id"]]);
-
- return $entry["meta"];
- }
- return false;
- }
-
- /**
- * Purge entries of a verify-type older than interval.
- *
- * @param string $type Verify type.
- * @param string $interval SQL compatible time interval
- */
- public static function purge($type, $interval)
- {
- $condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . " - INTERVAL " . $interval];
- dba::delete("openwebauth_token", $condition);
- }
-
-}
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
-use Friendica\Model\Verify;
+use Friendica\Model\OpenWebAuthToken;
use Friendica\Util\HTTPSignature;
use dba;
$token = random_string(32);
// Store the generated token in the databe.
- Verify::create('owt', 0, $token, $contact['addr']);
+ OpenWebAuthToken::create('owt', 0, $token, $contact['addr']);
$result = '';
<?php
/**
- * @file src/Util/HTTPSig.php
+ * @file src/Util/HTTPSignature.php
*/
namespace Friendica\Util;