]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/setpassword.php
Merge request #10 by aroque but in a slightly different version
[quix0rs-gnu-social.git] / scripts / setpassword.php
index b70689f030a7a67f8ec06315a3de41a9a88eb9e5..66964b2a088d58f252599646832ff17aaeec2bc8 100755 (executable)
@@ -1,8 +1,8 @@
 #!/usr/bin/env php
 <?php
 /*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -41,21 +41,12 @@ if (mb_strlen($password) < 6) {
     exit(1);
 }
 
-$user = User::staticGet('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";