@@ -274,14 +274,6 @@ public function gdn_auth_startAuthenticator_handler() {
274274 return ;
275275 }
276276
277- //TODO: https://github.com/topcoder-platform/forums/issues/108
278- //Clear cache for Guests
279- $ userModel = new UserModel ();
280- self ::log ('Guest permissions: ' , ['IsCacheEnabled: ' => Gdn::cache ()->activeEnabled () , 'Permissions ' => $ userModel ->getPermissions (0 )]);
281- // Delete cached data for userID=0 .
282- $ cacheCleared = $ userModel ->clearCache (0 );
283- self ::log ('After clearing cache for Guest: ' , ['IsCacheCleared ' => $ cacheCleared , 'Permissions ' => $ userModel ->getPermissions (0 )]);
284-
285277 if (!$ this ->isDefault ()) {
286278 self ::log ('Topcoder Auth0 is not a default provider ' , []);
287279 return ;
@@ -456,15 +448,15 @@ public function gdn_auth_startAuthenticator_handler() {
456448 'ValidateName ' => false
457449 ];
458450 $ userID = $ userModel ->save ($ userData , $ settings );
459-
460- $ roles = RoleModel::getByName ($ topcoderRoles );
461- // Add all Topcoder roles from a payload and Vanilla member
462- // User must have at least one role with the 'SignIn.Allow' permission to sign in
463- $ roleIDs = array_merge (array_keys ($ roles ), [8 ]);
464- $ userModel ->saveRoles ($ userID , $ roleIDs , false );
465-
466451 try {
467- ModelUtils::validationResultToValidationException ($ userModel , Gdn::locale (), true );
452+ if ($ userID > 0 ) {
453+ $ roles = RoleModel::getByName ($ topcoderRoles );
454+ // Add all Topcoder roles from a payload and Vanilla member
455+ // User must have at least one role with the 'SignIn.Allow' permission to sign in
456+ $ roleIDs = array_merge (array_keys ($ roles ), [8 ]);
457+ $ userModel ->saveRoles ($ userID , $ roleIDs , false );
458+ }
459+ ModelUtils::validationResultToValidationException ($ userModel , Gdn::locale (), true );
468460 self ::log ('Vanilla User was added ' , ['UserID ' => $ userID ]);
469461 } catch (\Garden \Schema \ValidationException $ e ) {
470462 self ::log ('Couldn \'t add a new user ' ,['Topcoder Username ' => $ topcoderUserName , 'error ' => $ e ->getMessage ()]);
@@ -475,7 +467,7 @@ public function gdn_auth_startAuthenticator_handler() {
475467 ['Topcoder Username ' => $ topcoderUserName , 'error ' => $ e ->getMessage ()]
476468 );
477469 }
478- if ($ userID === false ) {
470+ if (! $ userID ) {
479471 $ this ->fireEvent ('GuestSignIn ' , []);
480472 return ;
481473 }
@@ -1617,18 +1609,6 @@ private function getTopcoderProjectRoles($user, $resources = null, $roleResource
16171609 return $ roles ;
16181610 }
16191611
1620- // TODO: Debugging issues-108
1621- public function base_beforeNewDiscussionButton_handler ($ sender , $ args ) {
1622- $ newDiscussionModule = $ args ['NewDiscussionModule ' ];
1623-
1624- self ::log ('NewDiscussionModule_beforeNewDiscussionButton_handler ' , [
1625- 'UserID ' => Gdn::session ()->UserID ,
1626- 'ShowGuests ' => $ newDiscussionModule ->ShowGuests ,
1627- 'CategoryID ' => $ newDiscussionModule ->CategoryID , 'session.isValid ' => Gdn::session ()->isValid (),
1628- 'privilegedGuest ' => ($ newDiscussionModule ->ShowGuests && !Gdn::session ()->isValid ()),
1629- 'hasPermission ' => Gdn::session ()->checkPermission ('Vanilla.Discussions.Add ' , true , 'Category ' , 'any ' )]);
1630-
1631- }
16321612
16331613 // TODO: Debugging issues-108
16341614 public function gdn_dispatcher_beforeDispatch_handler ($ sender , $ args ) {
0 commit comments