]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/setpassword.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / scripts / setpassword.php
index 3e9f5c17ca3e9ab8473dd8e849e7282eb703ec54..b8feb207957ba3171714178c61e3975affa8bb30 100755 (executable)
@@ -27,7 +27,7 @@ Sets the password of user with name <username> to <password>
 
 END_OF_PASSWORD_HELP;
 
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
 
 if (count($args) < 2) {
     show_help();
@@ -41,21 +41,12 @@ if (mb_strlen($password) < 6) {
     exit(1);
 }
 
-$user = User::getKV('nickname', $nickname);
-
-if (!$user) {
-    print "No such user '$nickname'.\n";
+try {
+    $user = User::getByNickname($nickname);
+    $user->setPassword($password);
+} catch (NoSuchUserException $e) {
+    print $e->getMessage();
     exit(1);
 }
 
-$original = clone($user);
-
-$user->password = common_munge_password($password, $user->id);
-
-if (!$user->update($original)) {
-    print "Error updating user '$nickname'.\n";
-    exit(1);
-} else {
-    print "Password for user '$nickname' updated.\n";
-    exit(0);
-}
+print "Password for user '$nickname' updated.\n";