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() {