use crate::entity::prelude::*; use sea_orm::DatabaseConnection; use teloxide::{adaptors::Throttle, prelude::*}; /// Handles checking the master password /// /// # Returns /// /// Returns Ok(true) if the master password wasn't right or if it wasn't set /// /// # Errors /// /// Returns an error if there was an error getting or hashing the master password #[inline] pub async fn handle_master_password_check( bot: &Throttle, db: &DatabaseConnection, chat_id: ChatId, user_id: u64, master_pass: &str, ) -> crate::Result { match MasterPass::verify_master_pass(user_id, &master_pass, db).await { Ok(Some(true)) => Ok(false), Ok(Some(false)) => { bot.send_message(chat_id, "Wrong master password").await?; Ok(true) } Ok(None) => { bot.send_message(chat_id, "No master password set").await?; Ok(true) } Err(err) => Err(err.into()), } }