From 8224071881653961a8e3571df1e57c62d4c0a5f3 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 28 Nov 2023 21:09:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=99=BB=E5=BD=95=E6=97=A5=E5=BF=97msg?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E4=BD=BF=E7=94=A8=E5=8F=98=E9=87=8F=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/config/config/config.default.yaml | 2 +- src/modules/common/controller/account.go | 13 +++++-------- src/modules/common/controller/register.go | 3 +-- src/modules/system/controller/sys_log_login.go | 2 ++ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/framework/config/config/config.default.yaml b/src/framework/config/config/config.default.yaml index 86244380..db223dd3 100644 --- a/src/framework/config/config/config.default.yaml +++ b/src/framework/config/config/config.default.yaml @@ -112,7 +112,7 @@ security: refererWhiteList: - "127.0.0.1:3030" xframe: - enable: true + enable: false value: "SAMEORIGIN" csp: enable: true diff --git a/src/modules/common/controller/account.go b/src/modules/common/controller/account.go index 15eeeef3..b5730c78 100644 --- a/src/modules/common/controller/account.go +++ b/src/modules/common/controller/account.go @@ -54,12 +54,11 @@ func (s *AccountController) Login(c *gin.Context) { ) // 根据错误信息,创建系统访问记录 if err != nil { - msg := i18n.TKey(language, err.Error()) s.sysLogLoginService.CreateSysLogLogin( - loginBody.Username, commonConstants.STATUS_NO, msg+loginBody.Code, + loginBody.Username, commonConstants.STATUS_NO, err.Error(), ipaddr, location, os, browser, ) - c.JSON(200, result.ErrMsg(msg)) + c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error()))) return } @@ -78,9 +77,8 @@ func (s *AccountController) Login(c *gin.Context) { } else { s.accountService.UpdateLoginDateAndIP(&loginUser) // 登录成功 - msg := i18n.TKey(language, "app.common.loginSuccess") s.sysLogLoginService.CreateSysLogLogin( - loginBody.Username, commonConstants.STATUS_YES, msg, + loginBody.Username, commonConstants.STATUS_YES, "app.common.loginSuccess", ipaddr, location, os, browser, ) } @@ -152,7 +150,6 @@ func (s *AccountController) Router(c *gin.Context) { // POST /logout func (s *AccountController) Logout(c *gin.Context) { language := ctx.AcceptLanguage(c) - msg := i18n.TKey(language, "app.common.logoutSuccess") tokenStr := ctx.Authorization(c) if tokenStr != "" { // 存在token时记录退出信息 @@ -165,11 +162,11 @@ func (s *AccountController) Logout(c *gin.Context) { // 创建系统访问记录 退出成功 s.sysLogLoginService.CreateSysLogLogin( - userName, commonConstants.STATUS_YES, msg, + userName, commonConstants.STATUS_YES, "app.common.logoutSuccess", ipaddr, location, os, browser, ) } } - c.JSON(200, result.OkMsg(msg)) + c.JSON(200, result.OkMsg(i18n.TKey(language, "app.common.logoutSuccess"))) } diff --git a/src/modules/common/controller/register.go b/src/modules/common/controller/register.go index 484a47fe..85fa8285 100644 --- a/src/modules/common/controller/register.go +++ b/src/modules/common/controller/register.go @@ -68,9 +68,8 @@ func (s *RegisterController) Register(c *gin.Context) { ) // 根据错误信息,创建系统访问记录 if err != nil { - msg := err.Error() + " " + registerBody.Code s.sysLogLoginService.CreateSysLogLogin( - registerBody.Username, commonConstants.STATUS_NO, msg, + registerBody.Username, commonConstants.STATUS_NO, err.Error(), ipaddr, location, os, browser, ) c.JSON(200, result.ErrMsg(err.Error())) diff --git a/src/modules/system/controller/sys_log_login.go b/src/modules/system/controller/sys_log_login.go index 44941030..294bb9cb 100644 --- a/src/modules/system/controller/sys_log_login.go +++ b/src/modules/system/controller/sys_log_login.go @@ -50,6 +50,7 @@ func (s *SysLogLoginController) List(c *gin.Context) { (*arr)[i].LoginLocation = i18n.TKey(language, (*arr)[i].LoginLocation) (*arr)[i].OS = i18n.TKey(language, (*arr)[i].OS) (*arr)[i].Browser = i18n.TKey(language, (*arr)[i].Browser) + (*arr)[i].Msg = i18n.TKey(language, (*arr)[i].Msg) } } converI18n(language, &rows) @@ -135,6 +136,7 @@ func (s *SysLogLoginController) Export(c *gin.Context) { (*arr)[i].LoginLocation = i18n.TKey(language, (*arr)[i].LoginLocation) (*arr)[i].OS = i18n.TKey(language, (*arr)[i].OS) (*arr)[i].Browser = i18n.TKey(language, (*arr)[i].Browser) + (*arr)[i].Msg = i18n.TKey(language, (*arr)[i].Msg) } } converI18n(language, &rows)