Added check if the last admin user is to be deleted, and if that's the case, prevent it and return with error message.

This commit is contained in:
vraatikka
2013-08-04 23:02:29 +03:00
parent 6faca29281
commit f62cf1ea7e
3 changed files with 26 additions and 11 deletions

View File

@ -113,6 +113,10 @@ users_delete(USERS *users, char *user)
int del;
atomic_add(&users->stats.n_deletes, 1);
if (users->stats.n_entries == 1) {
atomic_add(&users->stats.n_entries, del * -1);
return 0;
}
del = hashtable_delete(users->data, user);
atomic_add(&users->stats.n_entries, del * -1);
return del;