1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Make the last activity timestamp and IP available through the API

This commit is contained in:
Quentin Gliech
2023-09-19 19:25:58 +02:00
parent b85655b944
commit 50558a7319
17 changed files with 2562 additions and 2329 deletions

View File

@ -92,6 +92,16 @@ impl BrowserSession {
pub async fn user_agent(&self) -> Option<&str> {
self.0.user_agent.as_deref()
}
/// The last IP address used by the session.
pub async fn last_active_ip(&self) -> Option<String> {
self.0.last_active_ip.map(|ip| ip.to_string())
}
/// The last time the session was active.
pub async fn last_active_at(&self) -> Option<DateTime<Utc>> {
self.0.last_active_at
}
}
/// An authentication records when a user enter their credential in a browser

View File

@ -142,6 +142,16 @@ impl CompatSession {
mas_data_model::CompatSessionState::Finished { .. } => CompatSessionState::Finished,
}
}
/// The last IP address used by the session.
pub async fn last_active_ip(&self) -> Option<String> {
self.session.last_active_ip.map(|ip| ip.to_string())
}
/// The last time the session was active.
pub async fn last_active_at(&self) -> Option<DateTime<Utc>> {
self.session.last_active_at
}
}
/// A compat SSO login represents a login done through the legacy Matrix login

View File

@ -128,6 +128,16 @@ impl OAuth2Session {
Ok(Some(User(user)))
}
/// The last IP address used by the session.
pub async fn last_active_ip(&self) -> Option<String> {
self.0.last_active_ip.map(|ip| ip.to_string())
}
/// The last time the session was active.
pub async fn last_active_at(&self) -> Option<DateTime<Utc>> {
self.0.last_active_at
}
}
/// The application type advertised by the client.