diff --git a/config/vanilla/bootstrap.early.php b/config/vanilla/bootstrap.early.php index 13924aa..278d498 100644 --- a/config/vanilla/bootstrap.early.php +++ b/config/vanilla/bootstrap.early.php @@ -56,4 +56,8 @@ ->column('Archived', 'tinyint(1)', '0') ->set(false, false); } + + // Delete the records with UserID=0 (Guests) from UserRole table + // FIX: https://github.com/topcoder-platform/forums/issues/108 + Gdn::sql()->delete('UserRole',['UserID' => 0]); } \ No newline at end of file diff --git a/vanilla/applications/dashboard/models/class.usermodel.php b/vanilla/applications/dashboard/models/class.usermodel.php index 78c1ddf..b2750d0 100644 --- a/vanilla/applications/dashboard/models/class.usermodel.php +++ b/vanilla/applications/dashboard/models/class.usermodel.php @@ -2493,6 +2493,10 @@ public function saveAdminUser($formPostValues) { * @param bool $RecordEvent */ public function saveRoles($UserID, $RoleIDs, $RecordEvent) { + if(!$UserID) { + throw new Exception(t('UserID is invalid.'), 400); + } + if (is_string($RoleIDs) && !is_numeric($RoleIDs)) { // The $RoleIDs are a comma delimited list of role names. $RoleNames = array_map('trim', explode(',', $RoleIDs));