Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2934378
D25621.1737785701.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
5 KB
Referenced Files
None
Subscribers
None
D25621.1737785701.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -5075,6 +5075,7 @@
'PhabricatorTypeaheadDatasourceTestCase' => 'applications/typeahead/datasource/__tests__/PhabricatorTypeaheadDatasourceTestCase.php',
'PhabricatorTypeaheadFunctionHelpController' => 'applications/typeahead/controller/PhabricatorTypeaheadFunctionHelpController.php',
'PhabricatorTypeaheadInvalidTokenException' => 'applications/typeahead/exception/PhabricatorTypeaheadInvalidTokenException.php',
+ 'PhabricatorTypeaheadLoginRequiredException' => 'applications/typeahead/exception/PhabricatorTypeaheadLoginRequiredException.php',
'PhabricatorTypeaheadModularDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php',
'PhabricatorTypeaheadMonogramDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadMonogramDatasource.php',
'PhabricatorTypeaheadProxyDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadProxyDatasource.php',
@@ -11811,6 +11812,7 @@
'PhabricatorTypeaheadDatasourceTestCase' => 'PhabricatorTestCase',
'PhabricatorTypeaheadFunctionHelpController' => 'PhabricatorTypeaheadDatasourceController',
'PhabricatorTypeaheadInvalidTokenException' => 'Exception',
+ 'PhabricatorTypeaheadLoginRequiredException' => 'Exception',
'PhabricatorTypeaheadModularDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
'PhabricatorTypeaheadMonogramDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorTypeaheadProxyDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
diff --git a/src/applications/people/typeahead/PhabricatorViewerDatasource.php b/src/applications/people/typeahead/PhabricatorViewerDatasource.php
--- a/src/applications/people/typeahead/PhabricatorViewerDatasource.php
+++ b/src/applications/people/typeahead/PhabricatorViewerDatasource.php
@@ -34,8 +34,12 @@
);
}
+ public function isFunctionWithLoginRequired($function) {
+ return true;
+ }
+
public function loadResults() {
- if ($this->getViewer()->getPHID()) {
+ if ($this->getViewer()->isLoggedIn()) {
$results = array($this->renderViewerFunctionToken());
} else {
$results = array();
@@ -45,7 +49,7 @@
}
protected function canEvaluateFunction($function) {
- if (!$this->getViewer()->getPHID()) {
+ if (!$this->getViewer()->isLoggedIn()) {
return false;
}
diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php
--- a/src/applications/search/controller/PhabricatorApplicationSearchController.php
+++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php
@@ -346,6 +346,8 @@
$body[] = $pager_box;
}
}
+ } catch (PhabricatorTypeaheadLoginRequiredException $ex) {
+ // TODO: understand how to render login page
} catch (PhabricatorTypeaheadInvalidTokenException $ex) {
$exec_errors[] = pht(
'This query specifies an invalid parameter. Review the '.
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
+++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
@@ -304,6 +304,15 @@
return parent::evaluateFunction($function, $argv);
}
+ protected function isFunctionWithLoginRequired($function) {
+ foreach ($this->getUsableDatasources() as $source) {
+ if ($source->isFunctionWithLoginRequired($function)) {
+ return true;
+ }
+ }
+ return parent::isFunctionWithLoginRequired($function);
+ }
+
public function renderFunctionTokens($function, array $argv_list) {
foreach ($this->getUsableDatasources() as $source) {
if ($source->canEvaluateFunction($function)) {
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
+++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
@@ -365,6 +365,14 @@
}
+ /**
+ * @task functions
+ */
+ protected function isFunctionRequiringLogin($function) {
+ return null;
+ }
+
+
/**
* @task functions
*/
@@ -498,6 +506,18 @@
if (!$this->canEvaluateFunction($function)) {
if (!$allow_partial) {
+
+ if ($this->isFunctionWithLoginRequired($function)) {
+ if (!$this->getViewer() || !$this->getViewer()->isLoggedIn()) {
+ throw new PhabricatorTypeaheadLoginRequiredException(
+ pht(
+ 'This datasource ("%s") requires to be logged-in to use the '.
+ 'function "%s(...)".',
+ get_class($this),
+ $function));
+ }
+ }
+
throw new PhabricatorTypeaheadInvalidTokenException(
pht(
'This datasource ("%s") can not evaluate the function "%s(...)".',
diff --git a/src/applications/typeahead/exception/PhabricatorTypeaheadLoginRequiredException.php b/src/applications/typeahead/exception/PhabricatorTypeaheadLoginRequiredException.php
new file mode 100644
--- /dev/null
+++ b/src/applications/typeahead/exception/PhabricatorTypeaheadLoginRequiredException.php
@@ -0,0 +1,6 @@
+<?php
+
+/**
+ * Exception thrown when a specific typehead requires login to be used.
+ */
+final class PhabricatorTypeaheadLoginRequiredException extends Exception {}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 25, 06:15 (6 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1147918
Default Alt Text
D25621.1737785701.diff (5 KB)
Attached To
Mode
D25621: Show login page if a search token requires a valid viewer
Attached
Detach File
Event Timeline
Log In to Comment