Can start Matrix authentication from UI
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::app_config::AppConfig;
|
||||
use crate::controllers::{HttpFailure, HttpResult};
|
||||
use crate::extractors::auth_extractor::{AuthExtractor, AuthenticatedMethod};
|
||||
use crate::extractors::session_extractor::MatrixGWSession;
|
||||
use crate::users::{User, UserEmail};
|
||||
use crate::users::{ExtendedUserInfo, User, UserEmail};
|
||||
use actix_remote_ip::RemoteIP;
|
||||
use actix_web::{HttpResponse, web};
|
||||
use light_openid::primitives::OpenIDConfig;
|
||||
@@ -108,7 +108,7 @@ pub async fn finish_oidc(
|
||||
|
||||
/// Get current user information
|
||||
pub async fn auth_info(auth: AuthExtractor) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(auth.user))
|
||||
Ok(HttpResponse::Ok().json(ExtendedUserInfo::from_user(auth.user).await?))
|
||||
}
|
||||
|
||||
/// Sign out user
|
||||
|
||||
@@ -166,3 +166,19 @@ impl APIToken {
|
||||
(self.last_used + self.max_inactivity) < time_secs()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, Debug, Clone)]
|
||||
pub struct ExtendedUserInfo {
|
||||
#[serde(flatten)]
|
||||
pub user: User,
|
||||
pub matrix_user_id: Option<String>,
|
||||
}
|
||||
|
||||
impl ExtendedUserInfo {
|
||||
pub async fn from_user(user: User) -> anyhow::Result<Self> {
|
||||
Ok(Self {
|
||||
user,
|
||||
matrix_user_id: None, // TODO
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user