mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Add user.enable conduit method
Test Plan: enabled a disabled user Reviewers: vrana, epriestley Reviewed By: vrana CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D2800
This commit is contained in:
parent
bf10eaf81c
commit
4b10707d4d
2 changed files with 71 additions and 0 deletions
|
@ -189,6 +189,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_user_Method' => 'applications/conduit/method/user/ConduitAPI_user_Method.php',
|
||||
'ConduitAPI_user_addstatus_Method' => 'applications/conduit/method/user/ConduitAPI_user_addstatus_Method.php',
|
||||
'ConduitAPI_user_disable_Method' => 'applications/conduit/method/user/ConduitAPI_user_disable_Method.php',
|
||||
'ConduitAPI_user_enable_Method' => 'applications/conduit/method/user/ConduitAPI_user_enable_Method.php',
|
||||
'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/ConduitAPI_user_find_Method.php',
|
||||
'ConduitAPI_user_info_Method' => 'applications/conduit/method/user/ConduitAPI_user_info_Method.php',
|
||||
'ConduitAPI_user_query_Method' => 'applications/conduit/method/user/ConduitAPI_user_query_Method.php',
|
||||
|
@ -1252,6 +1253,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_user_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_user_addstatus_Method' => 'ConduitAPI_user_Method',
|
||||
'ConduitAPI_user_disable_Method' => 'ConduitAPI_user_Method',
|
||||
'ConduitAPI_user_enable_Method' => 'ConduitAPI_user_Method',
|
||||
'ConduitAPI_user_find_Method' => 'ConduitAPI_user_Method',
|
||||
'ConduitAPI_user_info_Method' => 'ConduitAPI_user_Method',
|
||||
'ConduitAPI_user_query_Method' => 'ConduitAPI_user_Method',
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_user_enable_Method
|
||||
extends ConduitAPI_user_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Re-enable specified users (admin only).";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'phids' => 'required list<phid>',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'void';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
'ERR-PERMISSIONS' => 'Only admins can call this method.',
|
||||
'ERR-BAD-PHID' => 'Non existent user PHID.',
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$actor = $request->getUser();
|
||||
if (!$actor->getIsAdmin()) {
|
||||
throw new ConduitException('ERR-PERMISSIONS');
|
||||
}
|
||||
|
||||
$phids = $request->getValue('phids');
|
||||
|
||||
$users = id(new PhabricatorUser())->loadAllWhere(
|
||||
'phid IN (%Ls)',
|
||||
$phids);
|
||||
|
||||
if (count($phids) != count($users)) {
|
||||
throw new ConduitException('ERR-BAD-PHID');
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
id(new PhabricatorUserEditor())
|
||||
->setActor($actor)
|
||||
->disableUser($user, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue