atproto blogging
1use jacquard::{CowStr, IntoStatic, types::string::Did};
2
3#[derive(Clone, Debug, PartialEq)]
4pub struct AuthState {
5 pub did: Option<Did<'static>>,
6 pub session_id: Option<CowStr<'static>>,
7}
8
9impl Default for AuthState {
10 fn default() -> Self {
11 Self {
12 did: None,
13 session_id: None,
14 }
15 }
16}
17
18impl AuthState {
19 pub fn is_authenticated(&self) -> bool {
20 self.did.is_some()
21 }
22
23 pub fn set_authenticated(&mut self, did: Did<'_>, session_id: CowStr<'_>) {
24 self.did = Some(did.into_static());
25 self.session_id = Some(session_id.into_static());
26 }
27
28 pub fn clear(&mut self) {
29 self.did = None;
30 self.session_id = None;
31 }
32}