Refactor decryption logic to handle empty fields consistently across services
This commit is contained in:
0
src-tauri/src/shared/ai_models.rs
Normal file
0
src-tauri/src/shared/ai_models.rs
Normal file
24
src-tauri/src/shared/session.rs
Normal file
24
src-tauri/src/shared/session.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::shared::types::Lang;
|
||||
|
||||
pub struct Session {
|
||||
pub user_id: Option<String>,
|
||||
pub lang: Lang,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
pub fn new() -> Self {
|
||||
Self { user_id: None, lang: Lang::Fr }
|
||||
}
|
||||
|
||||
pub fn get_user_id(&self) -> Result<&str, String> {
|
||||
self.user_id.as_deref().ok_or_else(|| "No user session. Please log in first.".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub type SessionState = Arc<Mutex<Session>>;
|
||||
|
||||
pub fn create_session() -> SessionState {
|
||||
Arc::new(Mutex::new(Session::new()))
|
||||
}
|
||||
Reference in New Issue
Block a user