web 2.0

Fix bug: Delete user in Blogengine.NET 2.5

Problem

When you try to delete a user, you see the message:

"You cannot delete the last user with rights to create or edit users. Grant these rights to another user first before deleting this user."

this message caused by a wrong if condition. It verifies that you should have at lease 2 users with Administrator rights, it means, that you should not see that error message if you have 2 admins, and you delete a non admin user.

 

Fixing bug steps:

open file App_Code\UserServices.cs

find line 146, 

if (adminCount <= 1)
{
  return new JsonResponse() { Message = Resources.labels.cannotDeleteLastAdmin };
}

change the if condition from "<=" to  "<" 

if (adminCount < 1)
{
  return new JsonResponse() { Message = Resources.labels.cannotDeleteLastAdmin };
}

wich means that you should have at least one user with Administrator privileges.

Tags: