Can disconnect user from UI
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::extractors::auth_extractor::AuthExtractor;
|
||||
use crate::extractors::matrix_client_extractor::MatrixClientExtractor;
|
||||
use crate::matrix_connection::matrix_client::FinishMatrixAuth;
|
||||
use actix_web::HttpResponse;
|
||||
use crate::matrix_connection::matrix_manager::MatrixManagerMsg;
|
||||
use actix_web::{HttpResponse, web};
|
||||
use ractor::ActorRef;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct StartAuthResponse {
|
||||
@@ -28,3 +31,15 @@ pub async fn finish_auth(client: MatrixClientExtractor) -> HttpResult {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Logout user from Matrix server
|
||||
pub async fn logout(
|
||||
auth: AuthExtractor,
|
||||
manager: web::Data<ActorRef<MatrixManagerMsg>>,
|
||||
) -> HttpResult {
|
||||
manager
|
||||
.cast(MatrixManagerMsg::DisconnectClient(auth.user.email))
|
||||
.expect("Failed to communicate with matrix manager!");
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
@@ -102,6 +102,10 @@ async fn main() -> std::io::Result<()> {
|
||||
"/api/matrix_link/finish_auth",
|
||||
web::post().to(matrix_link_controller::finish_auth),
|
||||
)
|
||||
.route(
|
||||
"/api/matrix_link/logout",
|
||||
web::post().to(matrix_link_controller::logout),
|
||||
)
|
||||
})
|
||||
.workers(4)
|
||||
.bind(&AppConfig::get().listen_address)?
|
||||
|
||||
Reference in New Issue
Block a user