fix: 登录日志msg存储使用变量值
This commit is contained in:
@@ -112,7 +112,7 @@ security:
|
|||||||
refererWhiteList:
|
refererWhiteList:
|
||||||
- "127.0.0.1:3030"
|
- "127.0.0.1:3030"
|
||||||
xframe:
|
xframe:
|
||||||
enable: true
|
enable: false
|
||||||
value: "SAMEORIGIN"
|
value: "SAMEORIGIN"
|
||||||
csp:
|
csp:
|
||||||
enable: true
|
enable: true
|
||||||
|
|||||||
@@ -54,12 +54,11 @@ func (s *AccountController) Login(c *gin.Context) {
|
|||||||
)
|
)
|
||||||
// 根据错误信息,创建系统访问记录
|
// 根据错误信息,创建系统访问记录
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := i18n.TKey(language, err.Error())
|
|
||||||
s.sysLogLoginService.CreateSysLogLogin(
|
s.sysLogLoginService.CreateSysLogLogin(
|
||||||
loginBody.Username, commonConstants.STATUS_NO, msg+loginBody.Code,
|
loginBody.Username, commonConstants.STATUS_NO, err.Error(),
|
||||||
ipaddr, location, os, browser,
|
ipaddr, location, os, browser,
|
||||||
)
|
)
|
||||||
c.JSON(200, result.ErrMsg(msg))
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error())))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,9 +77,8 @@ func (s *AccountController) Login(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
s.accountService.UpdateLoginDateAndIP(&loginUser)
|
s.accountService.UpdateLoginDateAndIP(&loginUser)
|
||||||
// 登录成功
|
// 登录成功
|
||||||
msg := i18n.TKey(language, "app.common.loginSuccess")
|
|
||||||
s.sysLogLoginService.CreateSysLogLogin(
|
s.sysLogLoginService.CreateSysLogLogin(
|
||||||
loginBody.Username, commonConstants.STATUS_YES, msg,
|
loginBody.Username, commonConstants.STATUS_YES, "app.common.loginSuccess",
|
||||||
ipaddr, location, os, browser,
|
ipaddr, location, os, browser,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -152,7 +150,6 @@ func (s *AccountController) Router(c *gin.Context) {
|
|||||||
// POST /logout
|
// POST /logout
|
||||||
func (s *AccountController) Logout(c *gin.Context) {
|
func (s *AccountController) Logout(c *gin.Context) {
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
msg := i18n.TKey(language, "app.common.logoutSuccess")
|
|
||||||
tokenStr := ctx.Authorization(c)
|
tokenStr := ctx.Authorization(c)
|
||||||
if tokenStr != "" {
|
if tokenStr != "" {
|
||||||
// 存在token时记录退出信息
|
// 存在token时记录退出信息
|
||||||
@@ -165,11 +162,11 @@ func (s *AccountController) Logout(c *gin.Context) {
|
|||||||
// 创建系统访问记录 退出成功
|
// 创建系统访问记录 退出成功
|
||||||
|
|
||||||
s.sysLogLoginService.CreateSysLogLogin(
|
s.sysLogLoginService.CreateSysLogLogin(
|
||||||
userName, commonConstants.STATUS_YES, msg,
|
userName, commonConstants.STATUS_YES, "app.common.logoutSuccess",
|
||||||
ipaddr, location, os, browser,
|
ipaddr, location, os, browser,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(i18n.TKey(language, "app.common.logoutSuccess")))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,9 +68,8 @@ func (s *RegisterController) Register(c *gin.Context) {
|
|||||||
)
|
)
|
||||||
// 根据错误信息,创建系统访问记录
|
// 根据错误信息,创建系统访问记录
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := err.Error() + " " + registerBody.Code
|
|
||||||
s.sysLogLoginService.CreateSysLogLogin(
|
s.sysLogLoginService.CreateSysLogLogin(
|
||||||
registerBody.Username, commonConstants.STATUS_NO, msg,
|
registerBody.Username, commonConstants.STATUS_NO, err.Error(),
|
||||||
ipaddr, location, os, browser,
|
ipaddr, location, os, browser,
|
||||||
)
|
)
|
||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ func (s *SysLogLoginController) List(c *gin.Context) {
|
|||||||
(*arr)[i].LoginLocation = i18n.TKey(language, (*arr)[i].LoginLocation)
|
(*arr)[i].LoginLocation = i18n.TKey(language, (*arr)[i].LoginLocation)
|
||||||
(*arr)[i].OS = i18n.TKey(language, (*arr)[i].OS)
|
(*arr)[i].OS = i18n.TKey(language, (*arr)[i].OS)
|
||||||
(*arr)[i].Browser = i18n.TKey(language, (*arr)[i].Browser)
|
(*arr)[i].Browser = i18n.TKey(language, (*arr)[i].Browser)
|
||||||
|
(*arr)[i].Msg = i18n.TKey(language, (*arr)[i].Msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
converI18n(language, &rows)
|
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].LoginLocation = i18n.TKey(language, (*arr)[i].LoginLocation)
|
||||||
(*arr)[i].OS = i18n.TKey(language, (*arr)[i].OS)
|
(*arr)[i].OS = i18n.TKey(language, (*arr)[i].OS)
|
||||||
(*arr)[i].Browser = i18n.TKey(language, (*arr)[i].Browser)
|
(*arr)[i].Browser = i18n.TKey(language, (*arr)[i].Browser)
|
||||||
|
(*arr)[i].Msg = i18n.TKey(language, (*arr)[i].Msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
converI18n(language, &rows)
|
converI18n(language, &rows)
|
||||||
|
|||||||
Reference in New Issue
Block a user