feat: Implement Oauth2 login log service and repository
- Added Oauth2LogLoginService for managing user authorization logs. - Implemented methods for inserting logs, cleaning logs, and exporting log data. - Created a new file for Oauth2 login log service. refactor: Remove unused open_api module - Deleted the open_api.go file as it was not utilized in the project. fix: Update error codes in SysProfileController - Changed error codes for binding errors and user authentication errors to more descriptive values. fix: Update cache handling in SysConfig and SysDictType services - Modified Redis set operations to include expiration time for cached values. refactor: Update middleware authorization checks - Replaced PreAuthorize middleware with AuthorizeUser across multiple routes in system and tool modules for consistency. chore: Clean up trace and ws modules - Updated middleware authorization in trace and ws modules to use AuthorizeUser.
This commit is contained in:
@@ -104,18 +104,18 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
info, err := reqctx.LoginUser(c)
|
||||
if err != nil {
|
||||
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error())))
|
||||
c.JSON(401, resp.CodeMsg(401002, err.Error()))
|
||||
return
|
||||
}
|
||||
userId := loginUser.UserId
|
||||
userName := loginUser.User.UserName
|
||||
userId := info.UserId
|
||||
userName := info.User.UserName
|
||||
|
||||
// 检查手机号码格式并判断是否唯一
|
||||
if body.Phone != "" {
|
||||
@@ -172,10 +172,9 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
|
||||
rows := s.sysUserService.Update(userInfo)
|
||||
if rows > 0 {
|
||||
// 更新缓存用户信息
|
||||
loginUser.User = userInfo
|
||||
// 刷新令牌信息
|
||||
token.Cache(&loginUser)
|
||||
|
||||
info.User = userInfo
|
||||
// 更新信息
|
||||
token.UserInfoUpdate(info)
|
||||
c.JSON(200, resp.Ok(nil))
|
||||
return
|
||||
}
|
||||
@@ -203,17 +202,17 @@ func (s *SysProfileController) PasswordUpdate(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
info, err := reqctx.LoginUser(c)
|
||||
if err != nil {
|
||||
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error())))
|
||||
c.JSON(401, resp.CodeMsg(401002, err.Error()))
|
||||
return
|
||||
}
|
||||
userId := loginUser.UserId
|
||||
userId := info.UserId
|
||||
|
||||
// 查询当前登录用户信息得到密码值
|
||||
userInfo := s.sysUserService.FindById(userId)
|
||||
@@ -317,7 +316,7 @@ func (s *SysProfileController) PasswordForce(c *gin.Context) {
|
||||
// 更新缓存用户信息
|
||||
userInfo.Password = ""
|
||||
// 移除令牌信息
|
||||
token.Remove(reqctx.Authorization(c))
|
||||
token.UserInfoRemove(reqctx.Authorization(c))
|
||||
c.JSON(200, resp.Ok(nil))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user