]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/OpenWebAuthToken.php
Issue 9630: Prevent negative values for registered users
[friendica.git] / src / Model / OpenWebAuthToken.php
index cfb2fdd51da65d47fd1538b7d165b0df0e487275..cd80c3f62e3660f34051fcfd0998492b51fe4f14 100644 (file)
@@ -1,8 +1,24 @@
 <?php
-
 /**
- * @file src/Model/OpenWebAuthToken.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  */
+
 namespace Friendica\Model;
 
 use Friendica\Database\DBA;
@@ -16,12 +32,13 @@ class OpenWebAuthToken
        /**
         * Create an entry in the 'openwebauth-token' table.
         *
-        * @param string $type   Verify type.
-        * @param int    $uid    The user ID.
+        * @param string $type Verify type.
+        * @param int    $uid  The user ID.
         * @param string $token
         * @param string $meta
         *
         * @return boolean
+        * @throws \Exception
         */
        public static function create($type, $uid, $token, $meta)
        {
@@ -38,18 +55,19 @@ class OpenWebAuthToken
        /**
         * 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 $type Verify type.
+        * @param int    $uid  The user ID.
         * @param string $token
         *
         * @return string|boolean The meta enry or false if not found.
+        * @throws \Exception
         */
        public static function getMeta($type, $uid, $token)
        {
                $condition = ["type" => $type, "uid" => $uid, "token" => $token];
 
                $entry = DBA::selectFirst("openwebauth-token", ["id", "meta"], $condition);
-               if (DBA::is_result($entry)) {
+               if (DBA::isResult($entry)) {
                        DBA::delete("openwebauth-token", ["id" => $entry["id"]]);
 
                        return $entry["meta"];
@@ -62,6 +80,7 @@ class OpenWebAuthToken
         *
         * @param string $type     Verify type.
         * @param string $interval SQL compatible time interval
+        * @throws \Exception
         */
        public static function purge($type, $interval)
        {