basic implementation of verify_user_token
This commit is contained in:
parent
2a1b6bd8ae
commit
26bdc4c742
2 changed files with 8 additions and 1 deletions
|
@ -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(()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue