You've already forked AstralRinth
forked from didirus/AstralRinth
Sessions Route + Password Auth (#649)
* Sessions Route + Password Auth * run prep + fix clippy * changing passwords + logging in * register login
This commit is contained in:
@@ -11,7 +11,7 @@ pub struct SessionId(pub u64);
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Session {
|
||||
pub id: SessionId,
|
||||
pub session: String,
|
||||
pub session: Option<String>,
|
||||
pub user_id: UserId,
|
||||
|
||||
pub created: DateTime<Utc>,
|
||||
@@ -27,3 +27,30 @@ pub struct Session {
|
||||
pub country: Option<String>,
|
||||
pub ip: String,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
pub fn from(
|
||||
data: crate::database::models::session_item::Session,
|
||||
include_session: bool,
|
||||
) -> Self {
|
||||
Session {
|
||||
id: data.id.into(),
|
||||
session: if include_session {
|
||||
Some(data.session)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
user_id: data.user_id.into(),
|
||||
created: data.created,
|
||||
last_login: data.last_login,
|
||||
expires: data.expires,
|
||||
refresh_expires: data.refresh_expires,
|
||||
os: data.os,
|
||||
platform: data.platform,
|
||||
user_agent: data.user_agent,
|
||||
city: data.city,
|
||||
country: data.country,
|
||||
ip: data.ip,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user