outline InMemoryUserDB

This commit is contained in:
2025-12-18 19:15:44 -06:00
parent 05ba550a18
commit 3bb3ccf18c
3 changed files with 34 additions and 3 deletions

View File

@@ -7,7 +7,6 @@ use crate::shared::models::app::{Icon, IconID};
use crate::shared::email::Email;
use crate::shared::opaque::UserSecretKey;
use crate::shared::user_api::UserAPI;
//https://chatgpt.com/c/69441737-c990-8333-9737-7ac75232da1d
struct ClientApp<'a, R, U, C>
where

View File

@@ -8,4 +8,10 @@ pub trait ClientRepo {
async fn add_secret_key(&self, email: Email, user_secret_key: UserSecretKey) -> Result<(), String>;
async fn remove_secret_key(&self, email: &Email) -> Result<(), String>;
async fn add_code_logged_in(&self, email: &Email, login_session: CodeLoggedInSession) -> Result<(), String>;
}
}
// TODO: Implement in memory repo
// TODO: Implement flutter-storage
// https://chatgpt.com/c/69441737-c990-8333-9737-7ac75232da1d

View File

@@ -1,11 +1,14 @@
use std::collections::HashMap;
use std::sync::Arc;
use async_trait::async_trait;
use nkode_rs::nkode_core::keypad::Keypad;
use tokio::sync::Mutex;
use uuid::Uuid;
use crate::server::repository::user_repo::UserRepo;
use crate::shared::models::app::{CodeLoggedInSession, CodeLoginData, KeyLoggedInSession};
use crate::shared::models::app::{CodeLoggedInSession, CodeLoginData, Icon, KeyLoggedInSession};
use crate::shared::email::Email;
use crate::shared::signed_session_data::SignedSessionData;
use crate::shared::user_api::UserAPI;
pub struct InMemoryUserDB {
key_session: Arc<Mutex<HashMap<Uuid, KeyLoggedInSession>>>,
@@ -67,3 +70,26 @@ impl UserRepo for InMemoryUserDB {
.ok_or_else(|| "code login data not found for email".to_string())
}
}
#[async_trait]
impl UserAPI for InMemoryUserDB {
async fn get_new_icons(&self) -> Result<Vec<Icon>, String> {
todo!()
}
async fn get_login_data(&self, session: SignedSessionData<Email>) -> Result<CodeLoginData, String> {
todo!()
}
async fn is_code_registered(&self, session: SignedSessionData<Email>) -> Result<bool, String> {
todo!()
}
async fn set_code_login_data(&self, session: SignedSessionData<CodeLoginData>) -> Result<(), String> {
todo!()
}
async fn update_keypad(&self, keypad: SignedSessionData<Keypad>) -> Result<(), String> {
todo!()
}
}