use find_one for auth search

This commit is contained in:
DataHearth 2023-06-23 14:57:00 +02:00
parent 3237235fbf
commit a1c829d9d9
No known key found for this signature in database
GPG Key ID: E88FD356ACC5F3C4
2 changed files with 2 additions and 3 deletions

View File

@ -157,7 +157,7 @@ pub async fn add_auth_user(
#[description = "Discord user ID"] id: String,
) -> Result<(), Error> {
if !std::env::var("ADMIN_USERS")
.expect("missing ADMIN_USERS")
.unwrap_or(String::new())
.contains(&ctx.author().id.to_string())
{
ctx.say("You don't have permission to add a new user")

View File

@ -90,8 +90,7 @@ pub fn is_auth_user(discord_id: String) -> Result<bool, Error> {
.get()
.unwrap()
.collection::<AuthorizedUser>("authorized_users")
.find(doc! { "$eq": [{"discord_id": discord_id}] })
.find_one(doc! { "discord_id": discord_id })
.map_err(|err| Error::new(ErrorKind::InvalidInput, err))?
.next()
.is_some())
}