You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-09 04:22:45 +03:00
api: Add a finishedAt
property to the BrowserSession
and a state
property to all 3 session types
This commit is contained in:
@@ -73,6 +73,20 @@ impl BrowserSession {
|
||||
pub async fn created_at(&self) -> DateTime<Utc> {
|
||||
self.0.created_at
|
||||
}
|
||||
|
||||
/// When the session was finished.
|
||||
pub async fn finished_at(&self) -> Option<DateTime<Utc>> {
|
||||
self.0.finished_at
|
||||
}
|
||||
|
||||
/// The state of the session.
|
||||
pub async fn state(&self) -> BrowserSessionState {
|
||||
if self.0.finished_at.is_some() {
|
||||
BrowserSessionState::Finished
|
||||
} else {
|
||||
BrowserSessionState::Active
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An authentication records when a user enter their credential in a browser
|
||||
|
@@ -89,6 +89,14 @@ impl CompatSession {
|
||||
pub async fn sso_login(&self) -> Option<CompatSsoLogin> {
|
||||
self.1.as_ref().map(|l| CompatSsoLogin(l.clone()))
|
||||
}
|
||||
|
||||
/// The state of the session.
|
||||
pub async fn state(&self) -> CompatSessionState {
|
||||
match &self.0.state {
|
||||
mas_data_model::CompatSessionState::Valid => CompatSessionState::Active,
|
||||
mas_data_model::CompatSessionState::Finished { .. } => CompatSessionState::Finished,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A compat SSO login represents a login done through the legacy Matrix login
|
||||
|
@@ -78,6 +78,14 @@ impl OAuth2Session {
|
||||
}
|
||||
}
|
||||
|
||||
/// The state of the session.
|
||||
pub async fn state(&self) -> OAuth2SessionState {
|
||||
match &self.0.state {
|
||||
SessionState::Valid => OAuth2SessionState::Active,
|
||||
SessionState::Finished { .. } => OAuth2SessionState::Finished,
|
||||
}
|
||||
}
|
||||
|
||||
/// The browser session which started this OAuth 2.0 session.
|
||||
pub async fn browser_session(
|
||||
&self,
|
||||
|
Reference in New Issue
Block a user