Skip to content

Commit 4844a9b

Browse files
authored
Merge pull request #106 from topcoder-platform/mfe-issues-9
mfe-issues-8: Rollback some changes
2 parents 23385fc + 0a522f6 commit 4844a9b

File tree

1 file changed

+4
-57
lines changed

1 file changed

+4
-57
lines changed

Topcoder/class.topcoder.plugin.php

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ public function settingsController_topcoder_create($sender) {
187187
$cf->form()->validateRule('Plugins.Topcoder.RoleApiURI', 'ValidateRequired', t('You must provide Role API URI.'));
188188
$cf->form()->validateRule('Plugins.Topcoder.ResourceRolesApiURI', 'ValidateRequired', t('You must provide Resource Roles API URI.'));
189189
$cf->form()->validateRule('Plugins.Topcoder.ResourcesApiURI', 'ValidateRequired', t('You must provide Resources API URI.'));
190-
$isEmbedded = (bool) c('Garden.Embed.Allow');
191-
if ($isEmbedded) {
192-
$cf->form()->validateRule('Plugins.Topcoder.MicroFrontendsForumsURL', 'ValidateRequired', t('You must provide Micro-Frontends Forums URL.'));
193-
}
194190
$cf->form()->validateRule('Plugins.Topcoder.MemberProfileURL', 'ValidateRequired', t('You must provide Member Profile URL.'));
195191
if($cf->form()->getFormValue('Plugins.Topcoder.UseTopcoderAuthToken') == 1) {
196192
$cf->form()->validateRule('AuthenticationProvider.SignInUrl', 'ValidateRequired', t('You must provide SignIn URL.'));
@@ -213,7 +209,6 @@ public function settingsController_topcoder_create($sender) {
213209
'Plugins.Topcoder.RoleApiURI' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Role API URI'],
214210
'Plugins.Topcoder.ResourceRolesApiURI' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Resource Roles API URI'],
215211
'Plugins.Topcoder.ResourcesApiURI' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Resources API URI'],
216-
'Plugins.Topcoder.MicroFrontendsForumsURL' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Micro-Frontends Forums URL'],
217212
'Plugins.Topcoder.MemberProfileURL' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder Member Profile URL'],
218213
'Plugins.Topcoder.UseTopcoderAuthToken' => ['Control' => 'CheckBox', 'Default' => false, 'Description' => 'Use Topcoder access token to log in to Vanilla'],
219214
'AuthenticationProvider.SignInUrl' => ['Control' => 'TextBox', 'Default' => '', 'Description' => 'Topcoder SignIn URL'],
@@ -1964,67 +1959,19 @@ private static function topcoderUserCache($userFields) {
19641959

19651960
// Support Micro-frontends forums app
19661961
public function gdn_dispatcher_beforeDispatch_handler($sender, $args) {
1967-
$mfeUrl = c("Plugins.Topcoder.MicroFrontendsForumsURL");
1968-
$deliveryType = Gdn::request()->getQueryItem("DeliveryType");
1969-
$remoteUrl = Gdn::request()->getQueryItem("remote")? urldecode(Gdn::request()->getQueryItem("remote")):"";
1962+
$mfeUrl = c("Garden.Embed.RemoteUrl");
19701963
$isEmbedded = (bool) c('Garden.Embed.Allow', false);
19711964

19721965
$data = array(
1973-
'Garden.Embed.Allow' => c('Garden.Embed.Allow'),
1966+
'Garden.Embed.Allow' => $isEmbedded,
19741967
'MFEUrl' => $mfeUrl,
1975-
'RemoteQueryParam("remote")' => $remoteUrl,
1976-
'RemoteQueryParam("remote") == mfeUrl' => strcmp($mfeUrl, $remoteUrl) === 0,
19771968
'Request(current fullPath)' => Gdn::request()->getFullPath(),
1978-
'Request(current url)'=> Gdn::request()->getUrl(),
1979-
'currentUrl == mfeUrl' => strcmp($mfeUrl, Gdn::request()->getUrl()) === 0,
19801969
'Request(pathAndQuery)' => Gdn::request()->pathAndQuery(),
19811970
'Request(Method)'=> Gdn::request()->getMethod(),
1982-
'Request(DeliveryType)' =>Gdn::request()->getQueryItem("DeliveryType"),
1983-
'Request(DeliveryType calculated)'=> !($deliveryType == "" || $deliveryType == DELIVERY_TYPE_ALL),
19841971
'Permissions' => Gdn::session()->getPermissionsArray(),
1985-
);
1972+
);
19861973
logMessage(__FILE__, __LINE__, 'TopcoderPlugin', "Data", json_encode($data ));
1987-
1988-
self::log('gdn_dispatcher_beforeDispatch_handler', $data);
1989-
1990-
1991-
if(!$isEmbedded) {
1992-
return;
1993-
}
1994-
1995-
if(Gdn::request()->getMethod() != Gdn::request()::METHOD_GET) {
1996-
return;
1997-
}
1998-
if(stringBeginsWith(Gdn::request()->getPath(), '/api/') || stringBeginsWith(Gdn::request()->getPath(), '/dashboard')
1999-
|| stringBeginsWith(Gdn::request()->getPath(), '/settings')
2000-
|| stringBeginsWith(Gdn::request()->getPath(), '/embed/')
2001-
|| stringBeginsWith(Gdn::request()->getPath(), '/social/')
2002-
|| stringBeginsWith(Gdn::request()->getPath(), '/vanilla/')
2003-
|| stringBeginsWith(Gdn::request()->getPath(), '/utility/') || stringBeginsWith(Gdn::request()->getPath(), '/notifications/')
2004-
|| stringBeginsWith(Gdn::request()->getPath(), '/js/')
2005-
|| stringBeginsWith(Gdn::request()->getPath(), '/applications/')
2006-
|| stringBeginsWith(Gdn::request()->getPath(), '/themes/')
2007-
|| stringBeginsWith(Gdn::request()->getPath(), '/dist/')
2008-
|| stringBeginsWith(Gdn::request()->getPath(), '/css/')
2009-
|| stringBeginsWith(Gdn::request()->getPath(), '/plugins/')
2010-
|| stringBeginsWith(Gdn::request()->getPath(), '/resources/')) {
2011-
return;
2012-
}
2013-
2014-
if(!($deliveryType == "" || $deliveryType == DELIVERY_TYPE_ALL)) {
2015-
return;
2016-
}
2017-
if(stringBeginsWith(Gdn::request()->getUrl(), $mfeUrl)) {
2018-
return;
2019-
}
2020-
2021-
if(strlen($remoteUrl) > 0){
2022-
return;
2023-
} else {
2024-
safeHeader("HTTP/1.1 301 Moved Permanently");
2025-
safeHeader("Location: " . url($mfeUrl."/#/" . Gdn::request()->pathAndQuery()));
2026-
exit();
2027-
}
1974+
// self::log('gdn_dispatcher_beforeDispatch_handler', $data);
20281975
}
20291976

20301977
// Topcoder Cache is used for caching Topcoder Users by handle.

0 commit comments

Comments
 (0)