@@ -187,6 +187,10 @@ public function settingsController_topcoder_create($sender) {
187
187
$ cf ->form ()->validateRule ('Plugins.Topcoder.RoleApiURI ' , 'ValidateRequired ' , t ('You must provide Role API URI. ' ));
188
188
$ cf ->form ()->validateRule ('Plugins.Topcoder.ResourceRolesApiURI ' , 'ValidateRequired ' , t ('You must provide Resource Roles API URI. ' ));
189
189
$ 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
+ }
190
194
$ cf ->form ()->validateRule ('Plugins.Topcoder.MemberProfileURL ' , 'ValidateRequired ' , t ('You must provide Member Profile URL. ' ));
191
195
if ($ cf ->form ()->getFormValue ('Plugins.Topcoder.UseTopcoderAuthToken ' ) == 1 ) {
192
196
$ cf ->form ()->validateRule ('AuthenticationProvider.SignInUrl ' , 'ValidateRequired ' , t ('You must provide SignIn URL. ' ));
@@ -209,6 +213,7 @@ public function settingsController_topcoder_create($sender) {
209
213
'Plugins.Topcoder.RoleApiURI ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Role API URI ' ],
210
214
'Plugins.Topcoder.ResourceRolesApiURI ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Resource Roles API URI ' ],
211
215
'Plugins.Topcoder.ResourcesApiURI ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Resources API URI ' ],
216
+ 'Plugins.Topcoder.MicroFrontendsForumsURL ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Micro-Frontends Forums URL ' ],
212
217
'Plugins.Topcoder.MemberProfileURL ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Member Profile URL ' ],
213
218
'Plugins.Topcoder.UseTopcoderAuthToken ' => ['Control ' => 'CheckBox ' , 'Default ' => false , 'Description ' => 'Use Topcoder access token to log in to Vanilla ' ],
214
219
'AuthenticationProvider.SignInUrl ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder SignIn URL ' ],
@@ -284,6 +289,8 @@ public function gdn_auth_startAuthenticator_handler() {
284
289
if (!c ('Garden.Installed ' )) {
285
290
return ;
286
291
}
292
+ self ::log ('Embedded Settings ' , ['Garden.Embed.Allow ' => c ('Garden.Embed.Allow ' )]);
293
+
287
294
self ::log ('Cache ' , ['Active Cache ' => Gdn_Cache::activeCache (), 'Type ' =>Gdn::cache ()->type ()]);
288
295
289
296
if (!$ this ->isDefault ()) {
@@ -1955,11 +1962,69 @@ private static function topcoderUserCache($userFields) {
1955
1962
return $ cached ;
1956
1963
}
1957
1964
1958
- // TODO: Debugging issues-108
1965
+ // Support Micro-frontends forums app
1959
1966
public function gdn_dispatcher_beforeDispatch_handler ($ sender , $ args ) {
1960
- self ::log ('gdn_dispatcher_beforeDispatch_handler ' , [
1967
+ $ mfeUrl = c ("Plugins.Topcoder.MicroFrontendsForumsURL " );
1968
+ $ deliveryType = Gdn::request ()->getQueryItem ("DeliveryType " );
1969
+ $ remoteUrl = Gdn::request ()->getQueryItem ("remote " )? urldecode (Gdn::request ()->getQueryItem ("remote " )):"" ;
1970
+ $ isEmbedded = (bool ) c ('Garden.Embed.Allow ' , false );
1971
+
1972
+ $ data = array (
1973
+ 'Garden.Embed.Allow ' => c ('Garden.Embed.Allow ' ),
1974
+ 'MFEUrl ' => $ mfeUrl ,
1975
+ 'RemoteQueryParam("remote") ' => $ remoteUrl ,
1976
+ 'RemoteQueryParam("remote") == mfeUrl ' => strcmp ($ mfeUrl , $ remoteUrl ) === 0 ,
1977
+ 'Request(current fullPath) ' => Gdn::request ()->getFullPath (),
1978
+ 'Request(current url) ' => Gdn::request ()->getUrl (),
1979
+ 'currentUrl == mfeUrl ' => strcmp ($ mfeUrl , Gdn::request ()->getUrl ()) === 0 ,
1980
+ 'Request(pathAndQuery) ' => Gdn::request ()->pathAndQuery (),
1981
+ 'Request(Method) ' => Gdn::request ()->getMethod (),
1982
+ 'Request(DeliveryType) ' =>Gdn::request ()->getQueryItem ("DeliveryType " ),
1983
+ 'Request(DeliveryType calculated) ' => !($ deliveryType == "" || $ deliveryType == DELIVERY_TYPE_ALL ),
1961
1984
'Permissions ' => Gdn::session ()->getPermissionsArray (),
1962
- ]);
1985
+ );
1986
+ 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
+ }
1963
2028
}
1964
2029
1965
2030
// Topcoder Cache is used for caching Topcoder Users by handle.
0 commit comments