Format code
This commit is contained in:
@ -17,7 +17,6 @@ impl Default for SessionStatus {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||
pub struct SessionIdentityData {
|
||||
pub id: UserID,
|
||||
@ -33,7 +32,8 @@ impl<'a> SessionIdentity<'a> {
|
||||
}
|
||||
|
||||
pub fn deserialize_session_data(data: Option<String>) -> Option<SessionIdentityData> {
|
||||
let res: Option<SessionIdentityData> = data.as_deref()
|
||||
let res: Option<SessionIdentityData> = data
|
||||
.as_deref()
|
||||
.map(serde_json::from_str)
|
||||
.map(|f| match f {
|
||||
Ok(d) => Some(d),
|
||||
@ -55,8 +55,7 @@ impl<'a> SessionIdentity<'a> {
|
||||
}
|
||||
|
||||
fn set_session_data(&self, data: &SessionIdentityData) {
|
||||
let s = serde_json::to_string(data)
|
||||
.expect("Failed to serialize session data!");
|
||||
let s = serde_json::to_string(data).expect("Failed to serialize session data!");
|
||||
|
||||
self.0.remember(s);
|
||||
}
|
||||
@ -88,8 +87,6 @@ impl<'a> SessionIdentity<'a> {
|
||||
}
|
||||
|
||||
pub fn user_id(&self) -> UserID {
|
||||
self.get_session_data()
|
||||
.unwrap_or_default()
|
||||
.id
|
||||
self.get_session_data().unwrap_or_default().id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user