fix: 登录日志msg存储使用变量值

This commit is contained in:
TsMask
2023-11-28 21:09:44 +08:00
parent dd1058feb7
commit 8224071881
4 changed files with 9 additions and 11 deletions

View File

@@ -112,7 +112,7 @@ security:
refererWhiteList:
- "127.0.0.1:3030"
xframe:
enable: true
enable: false
value: "SAMEORIGIN"
csp:
enable: true

View File

@@ -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")))
}

View File

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

View File

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