From 63144d4dc0378ecc92b8cf4bab0674f9406f502f Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 25 Feb 2017 17:14:24 +0100 Subject: [PATCH] Add private method 'deleteUsersByColumnValue' to 'Administration' --- src/Administration.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Administration.php b/src/Administration.php index 0b6f361..e13f64d 100644 --- a/src/Administration.php +++ b/src/Administration.php @@ -9,6 +9,7 @@ namespace Delight\Auth; use Delight\Db\PdoDatabase; +use Delight\Db\Throwable\Error; require_once __DIR__ . '/Exceptions.php'; @@ -57,4 +58,28 @@ final class Administration extends UserManager { protected function throttle($actionType, $customSelector = null) {} + /** + * Deletes all existing users where the column with the specified name has the given value + * + * You must never pass untrusted input to the parameter that takes the column name + * + * @param string $columnName the name of the column to filter by + * @param mixed $columnValue the value to look for in the selected column + * @return int the number of deleted users + * @throws AuthError if an internal problem occurred (do *not* catch) + */ + private function deleteUsersByColumnValue($columnName, $columnValue) { + try { + return $this->db->delete( + 'users', + [ + $columnName => $columnValue + ] + ); + } + catch (Error $e) { + throw new DatabaseError(); + } + } + }