basic implementation of verify_user_token

This commit is contained in:
deneb 2024-02-10 13:10:54 +01:00
parent 2a1b6bd8ae
commit 26bdc4c742
2 changed files with 8 additions and 1 deletions

View file

@ -44,6 +44,12 @@ impl Authenticator {
#[instrument] #[instrument]
pub async fn verify_user_token(&self, username: &str, token: &UserToken) -> Result<(), ()> { 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(()),
}
} }
} }

View file

@ -49,6 +49,7 @@ impl SqliteDatabase {
} }
impl Database for SqliteDatabase { impl Database for SqliteDatabase {
// TODO: distinguish between invalid token and SQLX error
async fn get_token(&mut self, username: &str) -> Result<UserToken, sqlx::Error> { async fn get_token(&mut self, username: &str) -> Result<UserToken, sqlx::Error> {
let row: (String,) = query_as( let row: (String,) = query_as(
"SELECT token "SELECT token