From 8a896f196cd210bfa5c3b89d3d69735c33b1f3fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90lexander=20Kiselev?= Date: Fri, 7 Feb 2025 14:30:33 +0300 Subject: [PATCH] Added redirection to previous page after logout --- web/controller/base.go | 2 +- web/html/login.html | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web/controller/base.go b/web/controller/base.go index 492fc2dc..726284cb 100644 --- a/web/controller/base.go +++ b/web/controller/base.go @@ -17,7 +17,7 @@ func (a *BaseController) checkLogin(c *gin.Context) { if isAjax(c) { pureJsonMsg(c, http.StatusUnauthorized, false, I18nWeb(c, "pages.login.loginAgain")) } else { - c.Redirect(http.StatusTemporaryRedirect, c.GetString("base_path")) + c.Redirect(http.StatusTemporaryRedirect, c.GetString("base_path") + "?redirect=" + c.FullPath()) } c.Abort() } else { diff --git a/web/html/login.html b/web/html/login.html index 717adc56..c6cdbb48 100644 --- a/web/html/login.html +++ b/web/html/login.html @@ -502,7 +502,12 @@ const msg = await HttpUtil.post('/login', this.user); this.loading = false; if (msg.success) { - location.href = basePath + 'panel/'; + const redirect = new URLSearchParams(location.search).get('redirect'); + if (redirect && redirect.startsWith('/')) { + location.href = redirect; + } else { + location.href = basePath + 'panel/'; + } } }, async getSecretStatus() {