Refactor decryption logic to handle empty fields consistently across services

This commit is contained in:
natreex
2026-03-22 15:50:36 -04:00
parent 32d2b0fa5a
commit e8aaef108b
26 changed files with 226 additions and 120 deletions

View File

View 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()))
}