Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ Here is the matrix of deployed services:
| | Bazarr | 6767 (Localhost) | `http://localhost:6767` | Subtitles |
| | Prowlarr | 9696 (Localhost) | `http://localhost:9696` | Torrent Indexers |
| | Jackett | 9117 (Localhost) | `http://localhost:9117` | Indexer Proxy |
| **Download** | QBittorrent | 8080 (Localhost) | `http://localhost:8080` | Torrent Client |
| **Download** | QBittorrent | 8080 (Localhost), 6881 | `http://localhost:8080` | Torrent Client |
| **Apps** | Nextcloud | 4443 (Localhost) | `https://localhost:4443` | Personal Cloud |
| | Vaultwarden | 8001 (Localhost) | `http://localhost:8001` | Password Manager |
| | Filebrowser | 8002 (Localhost) | `http://localhost:8002` | Web File Manager |
| | Yourls | 8003 (Localhost) | `http://localhost:8003` | URL Shortener |
| | GLPI | 8088 (Localhost) | `http://localhost:8088` | IT Asset Management |
| | Gitea | 3000 (Localhost) | `http://localhost:3000` | Self-hosted Git |
| | Gitea | 3000 (Localhost), 2222 | `http://localhost:3000` | Self-hosted Git |
| | Roundcube | 8090 (Localhost) | `http://localhost:8090` | Webmail |
| | Mailserver | 25, 143, 587, 993 | - | Full Mail Server |
| | Syncthing | 8384 (Localhost), 22000 | `http://localhost:8384` | File Synchronization |
| | Syncthing | 8384 (Localhost), 22000, 21027 (UDP) | `http://localhost:8384` | File Synchronization |

---

Expand Down Expand Up @@ -319,16 +319,16 @@ Voici la matrice des services déployés :
| | Bazarr | 6767 (Localhost) | `http://localhost:6767` | Sous-titres |
| | Prowlarr | 9696 (Localhost) | `http://localhost:9696` | Indexeurs Torrent |
| | Jackett | 9117 (Localhost) | `http://localhost:9117` | Proxy Indexeurs |
| **Download** | QBittorrent | 8080 (Localhost) | `http://localhost:8080` | Client Torrent |
| **Download** | QBittorrent | 8080 (Localhost), 6881 | `http://localhost:8080` | Client Torrent |
| **Apps** | Nextcloud | 4443 (Localhost) | `https://localhost:4443` | Personal Cloud |
| | Vaultwarden | 8001 (Localhost) | `http://localhost:8001` | Password Manager |
| | Filebrowser | 8002 (Localhost) | `http://localhost:8002` | Web File Manager |
| | Yourls | 8003 (Localhost) | `http://localhost:8003` | URL Shortener |
| | GLPI | 8088 (Localhost) | `http://localhost:8088` | IT Asset Management |
| | Gitea | 3000 (Localhost) | `http://localhost:3000` | Self-hosted Git |
| | Gitea | 3000 (Localhost), 2222 | `http://localhost:3000` | Self-hosted Git |
| | Roundcube | 8090 (Localhost) | `http://localhost:8090` | Webmail |
| | Mailserver | 25, 143, 587, 993 | - | Full Mail Server |
| | Syncthing | 8384 (Localhost), 22000 | `http://localhost:8384` | Synchronisation de Fichiers |
| | Syncthing | 8384 (Localhost), 22000, 21027 (UDP) | `http://localhost:8384` | Synchronisation de Fichiers |

---

Expand Down
87 changes: 58 additions & 29 deletions server_manager/src/interface/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,22 +626,36 @@ async fn add_user_handler(State(state): State<SharedState>, session: Session, Fo
None => None,
};

let mut cache = state.users_cache.write().await;
let res = tokio::task::block_in_place(|| {
cache.manager.add_user(&payload.username, &payload.password, role_enum, quota_val)
});
let log_username = payload.username.clone();
let log_admin = session_user.username.clone();

if let Err(e) = res {
error!("Failed to add user: {}", e);
// In a real app we'd flash a message. Here just redirect.
} else {
info!("User {} added via Web UI by {}", payload.username, session_user.username);
// Update mtime to prevent unnecessary reload
let path = std::path::Path::new("users.yaml");
let fallback_path = std::path::Path::new("/opt/server_manager/users.yaml");
let file_path = if path.exists() { path } else { fallback_path };
if let Ok(m) = std::fs::metadata(file_path) {
cache.last_modified = m.modified().ok();
let mut cache = state.users_cache.write().await;
let mut manager_clone = cache.manager.clone();

let res = tokio::task::spawn_blocking(move || {
manager_clone.add_user(&payload.username, &payload.password, role_enum, quota_val)?;
Ok::<_, anyhow::Error>(manager_clone)
})
.await;

match res {
Ok(Ok(new_manager)) => {
cache.manager = new_manager;
info!("User {} added via Web UI by {}", log_username, log_admin);

// Update mtime to prevent unnecessary reload
let path = std::path::Path::new("users.yaml");
let fallback_path = std::path::Path::new("/opt/server_manager/users.yaml");
let file_path = if path.exists() { path } else { fallback_path };
if let Ok(m) = std::fs::metadata(file_path) {
cache.last_modified = m.modified().ok();
}
},
Ok(Err(e)) => {
error!("Failed to add user: {}", e);
},
Err(e) => {
error!("Join error: {}", e);
}
}

Expand All @@ -658,21 +672,36 @@ async fn delete_user_handler(State(state): State<SharedState>, session: Session,
return (StatusCode::FORBIDDEN, "Access Denied").into_response();
}

let mut cache = state.users_cache.write().await;
let res = tokio::task::block_in_place(|| {
cache.manager.delete_user(&username)
});
let log_username = username.clone();
let log_admin = session_user.username.clone();

if let Err(e) = res {
error!("Failed to delete user: {}", e);
} else {
info!("User {} deleted via Web UI by {}", username, session_user.username);
// Update mtime to prevent unnecessary reload
let path = std::path::Path::new("users.yaml");
let fallback_path = std::path::Path::new("/opt/server_manager/users.yaml");
let file_path = if path.exists() { path } else { fallback_path };
if let Ok(m) = std::fs::metadata(file_path) {
cache.last_modified = m.modified().ok();
let mut cache = state.users_cache.write().await;
let mut manager_clone = cache.manager.clone();

let res = tokio::task::spawn_blocking(move || {
manager_clone.delete_user(&username)?;
Ok::<_, anyhow::Error>(manager_clone)
})
.await;

match res {
Ok(Ok(new_manager)) => {
cache.manager = new_manager;
info!("User {} deleted via Web UI by {}", log_username, log_admin);

// Update mtime to prevent unnecessary reload
let path = std::path::Path::new("users.yaml");
let fallback_path = std::path::Path::new("/opt/server_manager/users.yaml");
let file_path = if path.exists() { path } else { fallback_path };
if let Ok(m) = std::fs::metadata(file_path) {
cache.last_modified = m.modified().ok();
}
},
Ok(Err(e)) => {
error!("Failed to delete user: {}", e);
},
Err(e) => {
error!("Join error: {}", e);
}
}

Expand Down