Page MenuHomePhabricator

D7574.id17095.diff
No OneTemporary

D7574.id17095.diff

Index: src/applications/auth/application/PhabricatorApplicationAuth.php
===================================================================
--- src/applications/auth/application/PhabricatorApplicationAuth.php
+++ src/applications/auth/application/PhabricatorApplicationAuth.php
@@ -41,6 +41,20 @@
->setHref('/logout/')
->setSelected(($controller instanceof PhabricatorLogoutController));
$items[] = $item;
+ } else {
+ if ($controller instanceof PhabricatorAuthController) {
+ // Don't show the "Login" item on auth controllers, since they're
+ // generally all related to logging in anyway.
+ } else {
+ $item = id(new PHUIListItemView())
+ ->addClass('core-menu-item')
+ ->setName(pht('Log In'))
+ // TODO: Login icon?
+ ->setIcon('power')
+ ->setWorkflow(true)
+ ->setHref('/auth/login/');
+ $items[] = $item;
+ }
}
return $items;
Index: src/applications/base/controller/PhabricatorController.php
===================================================================
--- src/applications/base/controller/PhabricatorController.php
+++ src/applications/base/controller/PhabricatorController.php
@@ -74,10 +74,15 @@
}
}
- if ($user->getIsDisabled() && $this->shouldRequireEnabledUser()) {
- $disabled_user_controller = new PhabricatorDisabledUserController(
- $request);
- return $this->delegateToController($disabled_user_controller);
+ if ($this->shouldRequireEnabledUser()) {
+ if ($user->isLoggedIn() && !$user->getIsApproved()) {
+ $controller = new PhabricatorAuthNeedsApprovalController($request);
+ return $this->delegateToController($controller);
+ }
+ if ($user->getIsDisabled()) {
+ $controller = new PhabricatorDisabledUserController($request);
+ return $this->delegateToController($controller);
+ }
}
$event = new PhabricatorEvent(
@@ -120,11 +125,6 @@
return $this->delegateToController($controller);
}
}
- if (!$user->getIsApproved()) {
- $controller = new PhabricatorAuthNeedsApprovalController($request);
- $this->setCurrentApplication($auth_application);
- return $this->delegateToController($controller);
- }
}
// If the user doesn't have access to the application, don't let them use
Index: src/applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php
===================================================================
--- src/applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php
+++ src/applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php
@@ -47,6 +47,11 @@
->setUsername('admin')
->save();
+ $u_notapproved = $this->generateNewTestUser()
+ ->setIsApproved(0)
+ ->setUsername('notapproved')
+ ->save();
+
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('phabricator.base-uri', 'http://'.$host);
$env->overrideEnvConfig('policy.allow-public', false);
@@ -68,6 +73,7 @@
array(
$u_public,
$u_disabled,
+ $u_notapproved,
));
@@ -86,6 +92,7 @@
$u_unverified,
$u_public,
$u_disabled,
+ $u_notapproved,
));
$this->checkAccess(
@@ -100,6 +107,7 @@
array(
$u_public,
$u_disabled,
+ $u_notapproved,
));
$env->overrideEnvConfig('auth.require-email-verification', false);
@@ -118,6 +126,7 @@
$u_unverified,
$u_public,
$u_disabled,
+ $u_notapproved,
));
@@ -132,6 +141,7 @@
$u_unverified,
$u_admin,
$u_disabled,
+ $u_notapproved,
),
array(
$u_public,
@@ -152,6 +162,7 @@
),
array(
$u_disabled,
+ $u_notapproved,
));
@@ -184,6 +195,7 @@
),
array(
$u_disabled,
+ $u_notapproved,
));
$env->overrideEnvConfig('policy.allow-public', false);
@@ -208,6 +220,7 @@
$u_admin,
$u_public,
$u_disabled,
+ $u_notapproved,
));
$this->checkAccess(
@@ -222,6 +235,7 @@
),
array(
$u_disabled,
+ $u_notapproved,
));
}
Index: src/applications/people/application/PhabricatorApplicationPeople.php
===================================================================
--- src/applications/people/application/PhabricatorApplicationPeople.php
+++ src/applications/people/application/PhabricatorApplicationPeople.php
@@ -62,13 +62,39 @@
);
}
+ public function loadStatus(PhabricatorUser $user) {
+ if (!$user->getIsAdmin()) {
+ return array();
+ }
+
+ $need_approval = id(new PhabricatorPeopleQuery())
+ ->setViewer($user)
+ ->withIsApproved(false)
+ ->execute();
+
+ if (!$need_approval) {
+ return array();
+ }
+
+ $status = array();
+
+ $count = count($need_approval);
+ $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
+ $status[] = id(new PhabricatorApplicationStatusView())
+ ->setType($type)
+ ->setText(pht('%d User(s) Need Approval', $count))
+ ->setCount($count);
+
+ return $status;
+ }
+
public function buildMainMenuItems(
PhabricatorUser $user,
PhabricatorController $controller = null) {
$items = array();
- if ($user->isLoggedIn()) {
+ if ($user->isLoggedIn() && $user->isUserActivated()) {
$image = $user->loadProfileImageURI();
$item = new PHUIListItemView();
Index: src/applications/settings/application/PhabricatorApplicationSettings.php
===================================================================
--- src/applications/settings/application/PhabricatorApplicationSettings.php
+++ src/applications/settings/application/PhabricatorApplicationSettings.php
@@ -37,7 +37,7 @@
$items = array();
- if ($user->isLoggedIn()) {
+ if ($user->isLoggedIn() && $user->isUserActivated()) {
$selected = ($controller instanceof PhabricatorSettingsMainController);
$item = new PHUIListItemView();
$item->setName(pht('Settings'));
Index: src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
===================================================================
--- src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
+++ src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
@@ -810,6 +810,11 @@
),
),
+ '%d User(s) Need Approval' => array(
+ '%d User Needs Approval',
+ '%d Users Need Approval',
+ ),
+
);
}
Index: src/view/page/menu/PhabricatorMainMenuView.php
===================================================================
--- src/view/page/menu/PhabricatorMainMenuView.php
+++ src/view/page/menu/PhabricatorMainMenuView.php
@@ -44,7 +44,7 @@
$search_button = '';
$app_button = '';
- if ($user->isLoggedIn()) {
+ if ($user->isLoggedIn() && $user->isUserActivated()) {
list($menu, $dropdowns) = $this->renderNotificationMenu();
$alerts[] = $menu;
$menus = array_merge($menus, $dropdowns);
@@ -91,8 +91,11 @@
'helpURI' => '/help/keyboardshortcut/',
);
- $show_search = ($user->isLoggedIn()) ||
- (PhabricatorEnv::getEnvConfig('policy.allow-public'));
+ if ($user->isLoggedIn()) {
+ $show_search = $user->isUserActivated();
+ } else {
+ $show_search = PhabricatorEnv::getEnvConfig('policy.allow-public');
+ }
if ($show_search) {
$search = new PhabricatorMainMenuSearchView();

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 28, 5:38 PM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720042
Default Alt Text
D7574.id17095.diff (7 KB)

Event Timeline