use find_one for auth search
This commit is contained in:
parent
3237235fbf
commit
a1c829d9d9
|
@ -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")
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue