@@ -274,14 +274,6 @@ public function gdn_auth_startAuthenticator_handler() {
274
274
return ;
275
275
}
276
276
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
-
285
277
if (!$ this ->isDefault ()) {
286
278
self ::log ('Topcoder Auth0 is not a default provider ' , []);
287
279
return ;
@@ -456,15 +448,15 @@ public function gdn_auth_startAuthenticator_handler() {
456
448
'ValidateName ' => false
457
449
];
458
450
$ 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
-
466
451
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 );
468
460
self ::log ('Vanilla User was added ' , ['UserID ' => $ userID ]);
469
461
} catch (\Garden \Schema \ValidationException $ e ) {
470
462
self ::log ('Couldn \'t add a new user ' ,['Topcoder Username ' => $ topcoderUserName , 'error ' => $ e ->getMessage ()]);
@@ -475,7 +467,7 @@ public function gdn_auth_startAuthenticator_handler() {
475
467
['Topcoder Username ' => $ topcoderUserName , 'error ' => $ e ->getMessage ()]
476
468
);
477
469
}
478
- if ($ userID === false ) {
470
+ if (! $ userID ) {
479
471
$ this ->fireEvent ('GuestSignIn ' , []);
480
472
return ;
481
473
}
@@ -1617,18 +1609,6 @@ private function getTopcoderProjectRoles($user, $resources = null, $roleResource
1617
1609
return $ roles ;
1618
1610
}
1619
1611
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
- }
1632
1612
1633
1613
// TODO: Debugging issues-108
1634
1614
public function gdn_dispatcher_beforeDispatch_handler ($ sender , $ args ) {
0 commit comments