use serde::{Deserialize, Serialize};

#[derive(Debug, Clone)]
pub enum Auth {
    Credentials { id: String, password: String },
    Session(SessionData),
    None,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SessionData {
    pub session_id: String,
    pub csrf_token: String,
    pub user_id: Option<String>,
}

impl SessionData {
    pub fn new(session_id: impl Into<String>, csrf_token: impl Into<String>) -> Self {
        Self {
            session_id: session_id.into(),
            csrf_token: csrf_token.into(),
            user_id: None,
        }
    }

    pub fn with_user_id(mut self, user_id: impl Into<String>) -> Self {
        self.user_id = Some(user_id.into());
        self
    }
}
