Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change password of a user in Phabricator

Let's say I have a user in Phabricator and I need to change his password (for example the email system is out of order and I need to set the password NOW).

How can I do that?

like image 824
tach Avatar asked Jun 23 '19 02:06

tach


People also ask

How do I change my Phabricator password?

Just met the same situation myself, you can execute a script to recover a user account in phabricator. after execution, a recover URL will be printed in the console, which can be used to reset a new password for the user.

Can an admin change a users password?

As an administrator, you can reset users' passwords to maintain account security. To do so, you must be signed in with an administrator account that has reset password privileges.

How do I force a user to change my first password?

To force a user to change his/her password, first of all the password must have expired and to cause a user's password to expire, you can use the passwd command, which is used to change a user's password by specifying the -e or --expire switch along with username as shown.


2 Answers

Just met the same situation myself, you can execute a script to recover a user account in phabricator.

bin/auth recover $USERNAME

after execution, a recover URL will be printed in the console, which can be used to reset a new password for the user.

related information: https://secure.phabricator.com/D18901

like image 105
YJ Park Avatar answered Oct 22 '22 11:10

YJ Park


It seems that Phabricator maintainers for some reason believe that administrators should not have full access to the user administration and don't provide tools for such task (e.g. https://stackoverflow.com/a/21249019/754982). One option is to hack the database directly, other is to add the functionality to the account_admin.php tool which used to have this functionality before (https://secure.phabricator.com/D18901?id=45357).

I submit patch for this script, which adds the functionality again. I'm not trying to do PR to the Phabricator codebase, I don't believe it would get accepted.

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
like image 44
tach Avatar answered Oct 22 '22 13:10

tach