rust/hedgewars-server/src/server/database.rs
changeset 15532 f1205f33bf5b
parent 15531 ede5f4ec48f3
child 15795 40929af15167
--- a/rust/hedgewars-server/src/server/database.rs	Thu Dec 26 21:55:51 2019 +0300
+++ b/rust/hedgewars-server/src/server/database.rs	Fri Dec 27 22:36:19 2019 +0300
@@ -86,6 +86,23 @@
         }
     }
 
+    pub fn get_checker_account(
+        &mut self,
+        nick: &str,
+        checker_password: &str,
+    ) -> Result<bool, Error> {
+        if let Some(pool) = &self.pool {
+            if let Some(row) = pool.first_exec(GET_ACCOUNT_QUERY, params! { "username" => nick })? {
+                let (mut password, _, _) = from_row_opt::<(String, i32, i32)>(row)?;
+                Ok(checker_password == password)
+            } else {
+                Ok(false)
+            }
+        } else {
+            Err(DriverError::SetupError.into())
+        }
+    }
+
     pub fn store_stats(&mut self, stats: &ServerStatistics) -> Result<(), Error> {
         if let Some(pool) = &self.pool {
             for mut stmt in pool.prepare(STORE_STATS_QUERY).into_iter() {