fix: 重置密码踢线失败时回退断开并记 ok_kick_failed
This commit is contained in:
@@ -104,28 +104,49 @@ func (h *Handler) kickEndpoint(ctx context.Context, id string) (bool, error) {
|
||||
|
||||
func (h *Handler) passwordResetKick(ctx context.Context, id string) (bool, error) {
|
||||
if h.resetKick != nil {
|
||||
return h.resetKick(ctx, id)
|
||||
kicked, err := h.resetKick(ctx, id)
|
||||
if err == nil {
|
||||
return kicked, nil
|
||||
}
|
||||
h.log.Error("password reset kick failed", "endpoint", id, "err", err)
|
||||
fallbackKicked, fallbackErr := h.kickEndpoint(ctx, id)
|
||||
if fallbackErr != nil {
|
||||
h.log.Error("password reset kick fallback failed", "endpoint", id, "err", fallbackErr)
|
||||
}
|
||||
return fallbackKicked, err
|
||||
}
|
||||
return h.kickEndpoint(ctx, id)
|
||||
kicked, err := h.kickEndpoint(ctx, id)
|
||||
if err != nil {
|
||||
h.log.Error("password reset kick failed", "endpoint", id, "err", err)
|
||||
}
|
||||
return kicked, err
|
||||
}
|
||||
|
||||
func (h *Handler) afterDisableKick(ctx context.Context, id string) {
|
||||
if h.disableKick != nil {
|
||||
_, _ = h.disableKick(ctx, id)
|
||||
if _, err := h.disableKick(ctx, id); err != nil {
|
||||
h.log.Error("disable kick failed", "endpoint", id, "err", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if h.identity == nil {
|
||||
_, _ = h.kickEndpoint(ctx, id)
|
||||
if _, err := h.kickEndpoint(ctx, id); err != nil {
|
||||
h.log.Error("disable kick failed", "endpoint", id, "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) afterDeleteKick(ctx context.Context, id string) {
|
||||
if h.deleteKick != nil {
|
||||
_, _ = h.deleteKick(ctx, id)
|
||||
if _, err := h.deleteKick(ctx, id); err != nil {
|
||||
h.log.Error("delete kick failed", "endpoint", id, "err", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if h.identity == nil {
|
||||
_, _ = h.kickEndpoint(ctx, id)
|
||||
if _, err := h.kickEndpoint(ctx, id); err != nil {
|
||||
h.log.Error("delete kick failed", "endpoint", id, "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,8 +578,12 @@ func (h *Handler) handleEndpointResetLoginPassword(w http.ResponseWriter, r *htt
|
||||
httpx.WriteError(w, http.StatusNotFound, "not_found", "端不存在")
|
||||
return
|
||||
}
|
||||
_, _ = h.passwordResetKick(r.Context(), id)
|
||||
h.auditP(p, "endpoint_reset_login_password", id, "ok", ip)
|
||||
_, kickErr := h.passwordResetKick(r.Context(), id)
|
||||
result := "ok"
|
||||
if kickErr != nil {
|
||||
result = "ok_kick_failed"
|
||||
}
|
||||
h.auditP(p, "endpoint_reset_login_password", id, result, ip)
|
||||
httpx.WriteOK(w, map[string]any{loginPasswordOnceKey: pw})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user