Automatically disconnect user when token is invalid

This commit is contained in:
2025-11-06 21:18:27 +01:00
parent 1ba5372468
commit 8bbbe7022f
5 changed files with 99 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ use actix_web::cookie::Key;
use actix_web::middleware::Logger;
use actix_web::{App, HttpServer, web};
use matrixgw_backend::app_config::AppConfig;
use matrixgw_backend::broadcast_messages::BroadcastMessage;
use matrixgw_backend::constants;
use matrixgw_backend::controllers::{auth_controller, matrix_link_controller, server_controller};
use matrixgw_backend::matrix_connection::matrix_manager::MatrixManagerActor;
@@ -24,6 +25,8 @@ async fn main() -> std::io::Result<()> {
.await
.expect("Failed to connect to Redis!");
let (ws_tx, _) = tokio::sync::broadcast::channel::<BroadcastMessage>(16);
// Auto create default account, if requested
if let Some(mail) = &AppConfig::get().unsecure_auto_login_email() {
User::create_or_update_user(mail, "Anonymous")
@@ -35,7 +38,7 @@ async fn main() -> std::io::Result<()> {
let (manager_actor, manager_actor_handle) = Actor::spawn(
Some("matrix-clients-manager".to_string()),
MatrixManagerActor,
(),
ws_tx.clone(),
)
.await
.expect("Failed to start Matrix manager actor!");
@@ -69,6 +72,7 @@ async fn main() -> std::io::Result<()> {
.app_data(web::Data::new(RemoteIPConfig {
proxy: AppConfig::get().proxy_ip.clone(),
}))
.app_data(web::Data::new(ws_tx.clone()))
// Server controller
.route("/robots.txt", web::get().to(server_controller::robots_txt))
.route(