From 73c4f373e5f30ae7b9c4be5cb6d0b69eecf92ab2 Mon Sep 17 00:00:00 2001 From: Azareal Date: Fri, 11 May 2018 16:18:49 +1000 Subject: [PATCH] Redirect to index when logged out via the Control Panel #5 --- panel_routes.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/panel_routes.go b/panel_routes.go index 645d3b30..3c9d1e88 100644 --- a/panel_routes.go +++ b/panel_routes.go @@ -1890,9 +1890,14 @@ func routePanelUsersEditSubmit(w http.ResponseWriter, r *http.Request, user comm // Log the user out as a safety precaution common.Auth.ForceLogout(targetUser.ID) } - targetUser.CacheRemove() - http.Redirect(w, r, "/panel/users/edit/"+strconv.Itoa(targetUser.ID)+"?updated=1", http.StatusSeeOther) + + // If we're changing our own password, redirect to the index rather than to a noperms error due to the force logout + if targetUser.ID == user.ID { + http.Redirect(w, r, "/", http.StatusSeeOther) + } else { + http.Redirect(w, r, "/panel/users/edit/"+strconv.Itoa(targetUser.ID)+"?updated=1", http.StatusSeeOther) + } return nil }