Added redirection to previous page after logout

This commit is contained in:
Аlexander Kiselev 2025-02-07 14:30:33 +03:00
parent 195effd177
commit 8a896f196c
2 changed files with 7 additions and 2 deletions

View file

@ -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 {

View file

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