insta_rs/
auth.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone)]
4pub enum Auth {
5    Credentials { id: String, password: String },
6    Session(SessionData),
7    None,
8}
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct SessionData {
12    pub session_id: String,
13    pub csrf_token: String,
14    pub user_id: Option<String>,
15}
16
17impl SessionData {
18    pub fn new(session_id: impl Into<String>, csrf_token: impl Into<String>) -> Self {
19        Self {
20            session_id: session_id.into(),
21            csrf_token: csrf_token.into(),
22            user_id: None,
23        }
24    }
25
26    pub fn with_user_id(mut self, user_id: impl Into<String>) -> Self {
27        self.user_id = Some(user_id.into());
28        self
29    }
30}