summaryrefslogtreecommitdiff
path: root/update.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-06-10 22:16:48 +0300
committerAndrew Dolgov <[email protected]>2022-06-10 22:16:48 +0300
commitd4be8218253ae887c284ef30a9a3a0ef10799b9a (patch)
treebdd04fd80b726ee29e91441567436dd652841dfb /update.php
parent8632c39eb2d5017d2137ccc599c900f57123893a (diff)
UserHelper, CLI: add a method to check user password
Diffstat (limited to 'update.php')
-rwxr-xr-xupdate.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/update.php b/update.php
index d63706b86..5e31c805b 100755
--- a/update.php
+++ b/update.php
@@ -101,6 +101,7 @@
"user-list" => "list all users",
"user-add:" => ["USER[:PASSWORD[:ACCESS_LEVEL=0]]", "add USER, prompts for password if unset"],
"user-remove:" => ["USERNAME", "remove USER"],
+ "user-check-password:" => ["USER:PASSWORD", "returns 0 if user has specified PASSWORD"],
"user-set-password:" => ["USER:PASSWORD", "sets PASSWORD of specified USER"],
"user-set-access-level:" => ["USER:LEVEL", "sets access LEVEL of specified USER"],
"user-exists:" => ["USER", "returns 0 if specified USER exists in the database"],
@@ -535,6 +536,21 @@
exit(1);
}
+ if (isset($options["user-check-password"])) {
+ list ($login, $password) = explode(":", $options["user-check-password"], 2);
+
+ $uid = UserHelper::find_user_by_login($login);
+
+ if (!$uid) {
+ Debug::log("Error: User not found: $login");
+ exit(1);
+ }
+
+ $rc = UserHelper::user_has_password($uid, $password);
+
+ exit($rc ? 0 : 1);
+ }
+
PluginHost::getInstance()->run_commands($options);
if (file_exists(Config::get(Config::LOCK_DIRECTORY) . "/$lock_filename"))