forked from GNUsocial/gnu-social
Added User->setPassword($password)
This commit is contained in:
parent
998db39b1a
commit
d7a8ee99af
@ -1012,6 +1012,16 @@ class User extends Managed_DataObject
|
|||||||
return !empty($this->password);
|
return !empty($this->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setPassword($password)
|
||||||
|
{
|
||||||
|
$orig = clone($this);
|
||||||
|
$this->password = common_munge_password($password, $this->getProfile());
|
||||||
|
|
||||||
|
if (!$this->update($orig)) {
|
||||||
|
throw new ServerException("Error updating user '{$nickname}'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function delPref($namespace, $topic)
|
public function delPref($namespace, $topic)
|
||||||
{
|
{
|
||||||
return $this->getProfile()->delPref($namespace, $topic);
|
return $this->getProfile()->delPref($namespace, $topic);
|
||||||
|
@ -41,21 +41,12 @@ if (mb_strlen($password) < 6) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::getKV('nickname', $nickname);
|
try {
|
||||||
|
$user = User::getByNickname($nickname);
|
||||||
if (!$user) {
|
$user->setPassword($password);
|
||||||
print "No such user '$nickname'.\n";
|
} catch (NoSuchUserException $e) {
|
||||||
|
print $e->getMessage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$original = clone($user);
|
print "Password for user '$nickname' updated.\n";
|
||||||
|
|
||||||
$user->password = common_munge_password($password, $user->getProfile());
|
|
||||||
|
|
||||||
if (!$user->update($original)) {
|
|
||||||
print "Error updating user '$nickname'.\n";
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
print "Password for user '$nickname' updated.\n";
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user