perf(management): optimize auth lookup in PatchAuthFileStatus

Use GetByID() for O(1) map lookup first, falling back to iteration
only for FileName matching. Consistent with pattern in disableAuth().
This commit is contained in:
Aldino Kemal
2026-01-19 20:05:37 +07:00
parent a1634909e8
commit 2f6004d74a

View File

@@ -777,11 +777,15 @@ func (h *Handler) PatchAuthFileStatus(c *gin.Context) {
// Find auth by name or ID // Find auth by name or ID
var targetAuth *coreauth.Auth var targetAuth *coreauth.Auth
auths := h.authManager.List() if auth, ok := h.authManager.GetByID(name); ok {
for _, auth := range auths { targetAuth = auth
if auth.FileName == name || auth.ID == name { } else {
targetAuth = auth auths := h.authManager.List()
break for _, auth := range auths {
if auth.FileName == name {
targetAuth = auth
break
}
} }
} }