refactor: 移除 Session 架构下已无用的 TokenVersion 即时吊销机制
- 删除 UserRepo.IncrementTokenVersion/FindTokenVersion 方法 - 从 userAuthStore/userAdminStore 接口移除 IncrementTokenVersion - 删除 middleware.tokenVersionStore 接口(中间件不再查询 token_version) - auth_service: DeleteAccount/InvalidateSessions 仅调用 DestroyByUID - admin_service: UpdateUserStatus/ResetUserToken 仅调用 DestroyByUID - FindByIDForAuth/FindByIDUnscoped Select 移除 token_version 列 - 新架构下登出/改密/封禁统一走 sessionManager.DestroyByUID,无需 token_version
This commit is contained in:
@ -259,11 +259,7 @@ func (s *AuthService) DeleteAccount(userID uint, password, reason string) error
|
||||
return err
|
||||
}
|
||||
|
||||
// 删除所有 session + 递增 token_version(向后兼容)
|
||||
if err := s.invalidateSessions(userID); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.userRepo.IncrementTokenVersion(userID)
|
||||
return s.invalidateSessions(userID)
|
||||
}
|
||||
|
||||
// invalidateSessions 销毁某用户的所有 session(内部方法)
|
||||
@ -273,10 +269,7 @@ func (s *AuthService) invalidateSessions(userID uint) error {
|
||||
|
||||
// InvalidateSessions 公开方法:销毁用户所有 session(供 admin 等外部调用)
|
||||
func (s *AuthService) InvalidateSessions(userID uint) error {
|
||||
if err := s.invalidateSessions(userID); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.userRepo.IncrementTokenVersion(userID)
|
||||
return s.sessionManager.DestroyByUID(userID)
|
||||
}
|
||||
|
||||
// UpdateProfile 修改个人资料
|
||||
|
||||
Reference in New Issue
Block a user