在Phabricator中更改用户密码

时间:2019-06-23 02:26:09

标签: phabricator change-password

假设我在Phabricator中有一个用户,我需要更改他的密码(例如,电子邮件系统出现故障,现在需要设置密码)。

我该怎么做?

2 个答案:

答案 0 :(得分:0)

似乎Phabricator的维护者出于某种原因认为管理员不应该具有对用户管理的完全访问权限,并且不提供用于执行此任务的工具(例如https://stackoverflow.com/a/21249019/754982)。一种选择是直接修改数据库,另一种是将功能添加到过去(https://secure.phabricator.com/D18901?id=45357)以前具有此功能的account_admin.php工具中。

我为此脚本提交了补丁,它再次添​​加了功能。我不是要对Phabricator代码库进行公关,但是我不相信它会被接受。

From 3340df50268d612c16ac17f48f69a9952688f47e Mon Sep 17 00:00:00 2001
From: root <user@localhost>
Date: Sun, 23 Jun 2019 02:44:24 +0200
Subject: [PATCH] Added possibility of changing passwords

---
 scripts/user/account_admin.php | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/scripts/user/account_admin.php b/scripts/user/account_admin.php
index 4e4500a2f..d5aa5f76e 100755
--- a/scripts/user/account_admin.php
+++ b/scripts/user/account_admin.php
@@ -112,6 +112,18 @@ if ($is_new) {
   $create_email = $email;
 }

+$changed_pass = false;
+// This disables local echo, so the user's password is not shown as they type
+// it.
+phutil_passthru('stty -echo');
+$password = phutil_console_prompt(
+  pht('Enter a password for this user [blank to leave unchanged]:'));
+phutil_passthru('stty echo');
+if (strlen($password)) {
+  $changed_pass = $password;
+}
+
+
 $is_system_agent = $user->getIsSystemAgent();
 $set_system_agent = phutil_console_confirm(
   pht('Is this user a bot?'),
@@ -148,6 +160,11 @@ if ($is_new) {
   printf($tpl, pht('Email'), '', $create_email);
 }

+printf($tpl, pht('Password'), null,
+  ($changed_pass !== false)
+    ? pht('Updated')
+    : pht('Unchanged'));
+
 printf(
   $tpl,
   pht('Bot'),
@@ -200,6 +217,17 @@ $user->openTransaction();
     $editor->updateUser($user, $verify_email);
   }

+  if ($changed_pass !== false) {
+    $password_envelope = new PhutilOpaqueEnvelope($changed_pass);
+
+    $account_type = PhabricatorAuthPassword::PASSWORD_TYPE_ACCOUNT;
+    $password_object = PhabricatorAuthPassword::initializeNewPassword($user, $account_type);
+
+    $password_object
+      ->setPassword($password_envelope, $user)
+      ->save();
+  }
+
   $editor->makeSystemAgentUser($user, $set_system_agent);

   $xactions = array();
@@ -223,6 +251,7 @@ $user->openTransaction();

   $transaction_editor->applyTransactions($user, $xactions);

+
 $user->saveTransaction();

 echo pht('Saved changes.')."\n";
-- 
2.20.1

答案 1 :(得分:0)

我自己也遇到过同样的情况,您可以执行脚本来恢复phabricator中的用户帐户。

bin/auth recover $USERNAME

执行后,将在控制台中打印一个恢复URL,可用于为用户重置新密码。

相关信息:https://secure.phabricator.com/D18901