Replace type UserID
with a structure
This commit is contained in:
@ -20,7 +20,7 @@ impl Default for SessionStatus {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||
pub struct SessionIdentityData {
|
||||
pub id: UserID,
|
||||
pub id: Option<UserID>,
|
||||
pub is_admin: bool,
|
||||
pub auth_time: u64,
|
||||
pub status: SessionStatus,
|
||||
@ -48,7 +48,7 @@ impl<'a> SessionIdentity<'a> {
|
||||
|
||||
// Check if session is valid
|
||||
if let Some(sess) = &res {
|
||||
if sess.id.is_empty() {
|
||||
if sess.id.is_none() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
@ -64,7 +64,7 @@ impl<'a> SessionIdentity<'a> {
|
||||
|
||||
pub fn set_user(&self, user: &User) {
|
||||
self.set_session_data(&SessionIdentityData {
|
||||
id: user.uid.clone(),
|
||||
id: Some(user.uid.clone()),
|
||||
is_admin: user.admin,
|
||||
auth_time: time(),
|
||||
status: SessionStatus::SignedIn,
|
||||
@ -101,6 +101,7 @@ impl<'a> SessionIdentity<'a> {
|
||||
|
||||
pub fn user_id(&self) -> UserID {
|
||||
self.get_session_data().unwrap_or_default().id
|
||||
.expect("UserID should never be null here!")
|
||||
}
|
||||
|
||||
pub fn auth_time(&self) -> u64 {
|
||||
|
Reference in New Issue
Block a user