From 26bdc4c7425d342ee0ea56d60cbe88d8bd678fff Mon Sep 17 00:00:00 2001 From: DenebTM Date: Sat, 10 Feb 2024 13:10:54 +0100 Subject: [PATCH] basic implementation of verify_user_token --- src/auth.rs | 8 +++++++- src/db.rs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/auth.rs b/src/auth.rs index 007be03..08643d3 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -44,6 +44,12 @@ impl Authenticator { #[instrument] pub async fn verify_user_token(&self, username: &str, token: &UserToken) -> Result<(), ()> { - todo!() + let mut db = self.db.lock().await; + + // TODO: (in db) distinguish between invalid token and SQLX error + match db.get_token(username).await { + Ok(_) => Ok(()), + Err(_) => Err(()), + } } } diff --git a/src/db.rs b/src/db.rs index c59e16a..35f7198 100644 --- a/src/db.rs +++ b/src/db.rs @@ -49,6 +49,7 @@ impl SqliteDatabase { } impl Database for SqliteDatabase { + // TODO: distinguish between invalid token and SQLX error async fn get_token(&mut self, username: &str) -> Result { let row: (String,) = query_as( "SELECT token