Skip to content

Commit

Permalink
feat: remove user cache when logout
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor-Lan committed Aug 24, 2022
1 parent 67a6aec commit cf85786
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/core/cmd/api/internal/logic/user/logoutlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"ark-admin-zero/app/core/cmd/api/internal/svc"
"ark-admin-zero/common/config"
"ark-admin-zero/common/errorx"
"ark-admin-zero/common/utils"

"github.com/zeromicro/go-zero/core/logx"
Expand All @@ -27,11 +26,10 @@ func NewLogoutLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogoutLogi
}

func (l *LogoutLogic) Logout() error {
userId := utils.GetUserId(l.ctx)
_, err := l.svcCtx.Redis.Del(config.SysPermMenuCachePrefix + strconv.FormatInt(userId, 10))
if err != nil {
return errorx.NewDefaultError(errorx.ServerErrorCode)
}
userId := strconv.FormatInt(utils.GetUserId(l.ctx), 10)
_, _ = l.svcCtx.Redis.Del(config.SysPermMenuCachePrefix + userId)
_, _ = l.svcCtx.Redis.Del(config.SysOnlineUserCachePrefix + userId)
_, _ = l.svcCtx.Redis.Del(config.SysUserIdCachePrefix + userId)

return nil
}
1 change: 1 addition & 0 deletions common/config/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
SysPermMenuCachePrefix = "cache:arkAdmin:permMenu:"
SysOnlineUserCachePrefix = "cache:arkAdmin:online:"
SysLoginCaptchaCachePrefix = "cache:arkAdmin:captcha:"
SysUserIdCachePrefix = "cache:arkAdmin:sysUser:id:"
SysSuperAdminUserId = 1
SysSuperAdminRoleId = 1
SysPermMenuPrefix = "/"
Expand Down

0 comments on commit cf85786

Please sign in to comment.