From e8a60d566d2eba6cf13bc80e2f8811ecaad7f145 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 2 Feb 2024 19:54:57 +0100 Subject: [PATCH] fix(ruins): remove dead code and unused table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - both table and logic where introduced with 84c1547c853081bf101528ecc60529e023ebc2ff - … and were incompletely removed again in 9b97c7350bda2f12869b1301beffbf172570273b Signed-off-by: Arthur Schiwon --- .../Version3001Date20200630193443.php | 24 --------- .../Version6001Date20240202183823.php | 54 +++++++++++++++++++ lib/UserBackend.php | 28 ---------- 3 files changed, 54 insertions(+), 52 deletions(-) create mode 100644 lib/Migration/Version6001Date20240202183823.php diff --git a/lib/Migration/Version3001Date20200630193443.php b/lib/Migration/Version3001Date20200630193443.php index df1a2cc8f..3f8f31283 100644 --- a/lib/Migration/Version3001Date20200630193443.php +++ b/lib/Migration/Version3001Date20200630193443.php @@ -62,30 +62,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table->setPrimaryKey(['uid']); } - if (!$schema->hasTable('user_saml_auth_token')) { - $table = $schema->createTable('user_saml_auth_token'); - $table->addColumn('id', Types::INTEGER, [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 4, - 'unsigned' => true, - ]); - $table->addColumn('uid', Types::STRING, [ - 'notnull' => true, - 'length' => 64, - 'default' => '', - ]); - $table->addColumn('name', Types::TEXT, [ - 'notnull' => true, - 'default' => '', - ]); - $table->addColumn('token', Types::STRING, [ - 'notnull' => true, - 'length' => 200, - 'default' => '', - ]); - $table->setPrimaryKey(['id']); - } return $schema; } } diff --git a/lib/Migration/Version6001Date20240202183823.php b/lib/Migration/Version6001Date20240202183823.php new file mode 100644 index 000000000..edaff2ff0 --- /dev/null +++ b/lib/Migration/Version6001Date20240202183823.php @@ -0,0 +1,54 @@ + + * + * @author Arthur Schiwon + * + * @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 . + * + */ + +namespace OCA\User_SAML\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Auto-generated migration step: Please modify to your needs! + */ +class Version6001Date20240202183823 extends SimpleMigrationStep { + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + if ($schema->hasTable('user_saml_auth_token')) { + $schema->dropTable('user_saml_auth_token'); + } + + return $schema; + } +} diff --git a/lib/UserBackend.php b/lib/UserBackend.php index 0872260ce..991c8099d 100644 --- a/lib/UserBackend.php +++ b/lib/UserBackend.php @@ -187,34 +187,6 @@ public function implementsActions($actions) { return (bool)($availableActions & $actions); } - /** - * Check if the provided token is correct - * @param string $uid The username - * @param string $password The password - * @return string - * - * Check if the password is correct without logging in the user - * returns the user id or false - */ - public function checkPassword($uid, $password) { - $qb = $this->db->getQueryBuilder(); - $qb->select('token') - ->from('user_saml_auth_token') - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) - ->setMaxResults(1000); - $result = $qb->execute(); - $data = $result->fetchAll(); - $result->closeCursor(); - - foreach ($data as $passwords) { - if (password_verify($password, $passwords['token'])) { - return $uid; - } - } - - return false; - } - /** * delete a user * @param string $uid The username of the user to delete