You've already forked authentication-service
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:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user