mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 20:29:03 +08:00
统一修复 sender_id 为空时权限误判导致的管理员操作被拒绝
This commit is contained in:
@@ -26,21 +26,15 @@ pub struct ImportStudentsParams {
|
||||
fn check_admin_permission(state: &Arc<RwLock<AppState>>, sender_id: Option<u32>) -> bool {
|
||||
let state_guard = state.read();
|
||||
let mut permissions = state_guard.permissions.write();
|
||||
if let Some(id) = sender_id {
|
||||
permissions.require_permission(id, PermissionLevel::Admin)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
let id = sender_id.unwrap_or(0);
|
||||
permissions.require_permission(id, PermissionLevel::Admin)
|
||||
}
|
||||
|
||||
fn check_view_permission(state: &Arc<RwLock<AppState>>, sender_id: Option<u32>) -> bool {
|
||||
let state_guard = state.read();
|
||||
let mut permissions = state_guard.permissions.write();
|
||||
if let Some(id) = sender_id {
|
||||
permissions.require_permission(id, PermissionLevel::View)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
let id = sender_id.unwrap_or(0);
|
||||
permissions.require_permission(id, PermissionLevel::View)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
Reference in New Issue
Block a user