summaryrefslogtreecommitdiff
path: root/classes/userhelper.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-11 10:22:27 +0300
committerAndrew Dolgov <[email protected]>2021-02-11 10:22:27 +0300
commit09e9f34bb495b435e826bce8cf716258039d4642 (patch)
tree60cdaf053a0af182cc66002790548caf09339c25 /classes/userhelper.php
parent7af8744c856545f62a2f24fd1a700f40b90b8e37 (diff)
add UserHelper::find_user_by_login() and rewrite some user checks to invoke it instead of going through PDO
Diffstat (limited to 'classes/userhelper.php')
-rw-r--r--classes/userhelper.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/classes/userhelper.php b/classes/userhelper.php
index 4519f2803..6c6ad10d9 100644
--- a/classes/userhelper.php
+++ b/classes/userhelper.php
@@ -1,8 +1,7 @@
<?php
class UserHelper {
- static function authenticate($login, $password, $check_only = false, $service = false) {
-
+ static function authenticate(string $login = null, string $password = null, bool $check_only = false, string $service = null) {
if (!SINGLE_USER_MODE) {
$user_id = false;
$auth_module = false;
@@ -71,7 +70,7 @@ class UserHelper {
}
}
- static function load_user_plugins($owner_uid, $pluginhost = false) {
+ static function load_user_plugins(int $owner_uid, PluginHost $pluginhost = null) {
if (!$pluginhost) $pluginhost = PluginHost::getInstance();
@@ -145,4 +144,17 @@ class UserHelper {
}
}
+ static function find_user_by_login(string $login) {
+ $pdo = Db::pdo();
+
+ $sth = $pdo->prepare("SELECT id FROM ttrss_users WHERE
+ LOWER(login) = LOWER(?)");
+ $sth->execute([$login]);
+
+ if ($row = $sth->fetch()) {
+ return $row["id"];
+ }
+
+ return false;
+ }
}