mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-05 07:37:25 +02:00
Add private method 'deleteUsersByColumnValue' to 'Administration'
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
namespace Delight\Auth;
|
namespace Delight\Auth;
|
||||||
|
|
||||||
use Delight\Db\PdoDatabase;
|
use Delight\Db\PdoDatabase;
|
||||||
|
use Delight\Db\Throwable\Error;
|
||||||
|
|
||||||
require_once __DIR__ . '/Exceptions.php';
|
require_once __DIR__ . '/Exceptions.php';
|
||||||
|
|
||||||
@@ -57,4 +58,28 @@ final class Administration extends UserManager {
|
|||||||
|
|
||||||
protected function throttle($actionType, $customSelector = null) {}
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user