Notification claims X users for approval, but none are found

This looks like a bug, but I can’t see how to reproduce it.

I get a notification PM that says:

But when I click the review link, there are no pending users. In /admin/users I see some users that have not validated their email addresses.

I can’t tell if the notification is producing the wrong number, or if there somehow exist users waiting approval that are not showing up when searching for them, or if somehow users who haven’t validated email are getting counted as pending for notifications but not for approval.

3 Likes

not to be Ms Obvious but is allow_new_registrations unchecked by chance? clearly you have the must_approve_users setting enabled and i’m not sure how that is affected if registration is disabled. :thinking: i would think the registration setting would override any account creation though and disable it. no that makes no sense either…

It’s almost certainly something obvious, so I welcome your help.

Yes, both of those are checked. Some people are getting registered and approved. It’s just that the number claimed to be waiting does not match the number claimed in the notification. It told me 5, and there had been only 2 in the past several days.

1 Like

very odd indeed. kinda sounds like something in the user registration is being rejected after the approval request is sent (counted) for review…

3 Likes

Are there reviewed users when you show all reviewed items, or maybe from the staff logs? :person_shrugging:

I often got PMs/reminds of reviewable items that are already reviewed, so nothing shows up.

I asssumed that the issue was that someone else approved the users before I (or the site owner) got to them, but I can’t make the numbers add up that way).

Can a user delete their account before their registration is approved?

Maybe? I don’t think so, as they’d need to log in to do that and they can’t log in until they are approved (but I didn’t check the code or anything like that)

I found this topic while searching before filing a bug report, so adding to it.

TL;DR the query for the notification is wrong because it counts rejected users as well.

Notification: 16 users waiting for approval, click the link, see only 2.

The query used for the notification is this

puts AdminUserIndexQuery.new(query: "pending", stats: false).find_users_query.to_sql

SELECT "users".* FROM "users" 
WHERE (suspended_till IS NULL OR suspended_till <= '2023-11-13 11:05:23.225614') 
AND "users"."approved" = FALSE 
AND "users"."active" = TRUE 
ORDER BY users.created_at DESC,users.username

which, in my case, gives me 16 users

[4479, 4472, 4456, 4446, 4443, 4430, 4302, 4291, 4206, 4199, 4178, 4168, 4131, 4061, 3677, 3642]

Throwing these ids into the Reviewables queue gives me 2 users that actually need to be approved (status 0) and 14 users that have already been rejected (status 2)

ReviewableUser.where(type: 'ReviewableUser')
  .where(target_id: ids)
  .pluck(:target_id, :status)

[[3642, 2], [3677, 2], [4061, 2], [4131, 2], [4168, 2], 
[4178, 2], [4199, 2], [4206, 2], [4291, 2], [4302, 2], 
[4430, 2], [4443, 2], [4446, 2], [4456, 2], [4472, 0], [4479, 0]]
2 Likes

Someone complained about this today. Before finding all of this, I “solved” the problem something like this:

bad=User.where(approved: false);
bad.each do |user| puts "https://community.open-emr.org/admin/users/#{user.id}/#{user.username}"; end;

This prints the admin URLs for all of the users so you can then approve or delete them there, I think.

So I guess this is still a bug.

Oh, and so then:

ids=bad.pluck(:id);
ReviewableUser.where(type: 'ReviewableUser')
  .where(target_id: ids)
  .pluck(:target_id, :status)

Now returns something like this:

=> [[4610, "rejected"], [4527, "rejected"], [4643, "rejected"], [4648, "rejected"]]

So maybe those need to deleted from ReviewableUser?

Or maybe just delete the users?

2 Likes

As a moderator (not an Admin), I was able to list the Rejected users in the unfiltered Review Queue. But not find them in the User section nor access the User editor for rejected users from the Review Queue.

this is the Filter parameters used for the Review queue for

https://gramps.discourse.group/review?additional_filters={}&sort_order=score&status=rejected&type=ReviewableUser

So, either moderators need to be able to find “Rejected” and “No” approval status users in the User tabs or be able to navigate to the user editor from the Review Queue.

1 Like

I’m having this same issue and was sent here by support.

I am the only staff or admin on the account, so it’s definitely this bug not another admin having approved them.

For all three of these notifications, when I clicked the pending queue, there were no users waiting for approval:

2 Likes

I’ve recently turned on approval for new users. I get very few - this is a trickle, not a flood. It’s 100% reproducible that I get the notification, I approve the user (usually approve) and then within about a minute I get a new phantom notification, with the review queue actually being freshly empty.

It feels like maybe a race condition.

You can use a data explorer query to find the user you don’t see in the queue and approve them directly on their admin page.

SELECT id as user_id
FROM users
WHERE approved = false
AND active = true

This is what I did recently. I also get this message every 7 days. So I used the query and this was the result

And I verified it in the users admin page

But I still have to find out why the button doesn’t work in my case. I haven’t had a chance to look at it yet.
Hopefully the button just works for you. I think there is more than one bug which results in those notifications but no users in the queue. RGJ found something about rejected users, I reported a case where some existing users aren’t approved when the setting is enabled.

Maybe I had something similar, although your search there which in your case matches a chat in my case does not match anything other than the user. The explorer query

SELECT id as user_id
FROM users
WHERE approved = false
AND active = true

returned one user, who is by no means new:

Joined Apr 9, 2021
Last Post Apr 16
Seen Apr 16
Views 1308
Trust Level member

Hmm, I can’t approve them manually. Something is wrong!

Edit: I’m not the only one - see this new topic: Approval button on user’s profile doesn’t work

details - OT here

In the admin interface I see the Approve button, I press it, nothing happens. In the browser console I see a 500 error.

requestedUrl:
“/admin/users/332/approve”
responseText:
"<!DOCTYPE html>\n<html>\n<head>\n <title>Oops - Error 500</title>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n</head>\n<body>\n <h1>Oops</h1>\n <p>The software powering this discussion forum encountered an unexpected problem. We apologize for the inconvenience…

1 Like

Now I’m more concerned because we’re on the Starter plan, so I can’t use Data Explorer. This makes me think that maybe there are users waiting for approval, but I just can’t see them.

I have never noticed more users than the title of the message that notified me said. The message says 1 and I only found 1.

But even without Data Explorer, you can efficiently find unapproved users. You can export your user directory using the button at the top right of /admin/users

and open that with whatever you prefer to check for users where approved is false. I used Excel, and you can see that there is really only one user:

1 Like

@Moin so helpful, why didn’t I think of that?

Gosh, the export shows that there are users who are not approved! Even though the review page is still empty:

This seems like a serious bug. These users would have been extremely frustrated if no one had ever gotten to them. Before I search on them to approve them, I’ll give Discourse a chance to investigate the bug of them not showing up in /review.

1 Like

Were their accounts activated? I sometimes have a few of those users too because they haven’t yet verified their email address. And it makes sense that they only require staff approval (=time) after confirming the email.