From 80ac10eee763ad0feeab90777b68d7e19c52bb69 Mon Sep 17 00:00:00 2001 From: bwdutton Date: Thu, 4 Jun 2020 00:42:21 -0700 Subject: [PATCH] add CLI password reset: php index.php passwordreset or php index.php passwordreset username --- index.php | 7 +++ modules/gallery/controllers/passwordreset.php | 49 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 modules/gallery/controllers/passwordreset.php diff --git a/index.php b/index.php index e6636cf1..e3356fee 100644 --- a/index.php +++ b/index.php @@ -73,6 +73,13 @@ if (PHP_SAPI == "cli") { case "install": include("installer/index.php"); exit(0); + case "passwordreset": + $username = empty($_SERVER['argv'][2]) ? 'admin' : $_SERVER['argv'][2]; + # need to quote/escape this? + $_SERVER["argv"] = array("index.php", "{$arg_1}/index/$username"); + define("TEST_MODE", 0); + define("VARPATH", realpath("var") . "/"); + break; case "upgrade": case "package": $_SERVER["argv"] = array("index.php", "{$arg_1}r/$arg_1"); diff --git a/modules/gallery/controllers/passwordreset.php b/modules/gallery/controllers/passwordreset.php new file mode 100644 index 00000000..e4d0d4a9 --- /dev/null +++ b/modules/gallery/controllers/passwordreset.php @@ -0,0 +1,49 @@ +password = $password; + $user->save(); + + print "We reset the password for: + username: {$user->name} + password: $password + +"; + } +}