fix: 修复 退出登录 auth问题
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m45s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m45s
This commit is contained in:
parent
5f884ed737
commit
a542a6df46
@ -76,13 +76,7 @@ func (l *UnbindDeviceLogic) logoutUnbind(userInfo *user.User, device *user.Devic
|
||||
return err
|
||||
}
|
||||
|
||||
// 4. Kick 设备
|
||||
l.svcCtx.DeviceManager.KickDevice(device.UserId, device.Identifier)
|
||||
|
||||
// 5. 清除该用户所有 session(旧 token 全部失效)
|
||||
l.clearAllSessions(userInfo.Id)
|
||||
|
||||
// 6. 清理邮箱相关缓存
|
||||
// 4. 事务提交后立即清缓存(避免 KickDevice/clearAllSessions 触发重连时命中旧缓存)
|
||||
for _, am := range authMethods {
|
||||
if am.AuthType == "email" && am.AuthIdentifier != "" {
|
||||
cacheKey := fmt.Sprintf("cache:user:email:%s", am.AuthIdentifier)
|
||||
@ -95,8 +89,6 @@ func (l *UnbindDeviceLogic) logoutUnbind(userInfo *user.User, device *user.Devic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 清理当前用户缓存
|
||||
if clearErr := l.svcCtx.UserModel.ClearUserCache(l.ctx, userInfo); clearErr != nil {
|
||||
l.Errorw("clear user cache failed",
|
||||
logger.Field("user_id", userInfo.Id),
|
||||
@ -104,7 +96,13 @@ func (l *UnbindDeviceLogic) logoutUnbind(userInfo *user.User, device *user.Devic
|
||||
)
|
||||
}
|
||||
|
||||
// 8. 清理受影响的家庭成员缓存(家庭解散后成员需感知变化)
|
||||
// 5. Kick 设备(缓存已清,重连时 FindOne 会查到最新数据)
|
||||
l.svcCtx.DeviceManager.KickDevice(device.UserId, device.Identifier)
|
||||
|
||||
// 6. 清除该用户所有 session(旧 token 全部失效)
|
||||
l.clearAllSessions(userInfo.Id)
|
||||
|
||||
// 7. 清理受影响的家庭成员缓存(家庭解散后成员需感知变化)
|
||||
for _, memberID := range familyMemberIDs {
|
||||
if memberUser, findErr := l.svcCtx.UserModel.FindOne(l.ctx, memberID); findErr == nil {
|
||||
if clearErr := l.svcCtx.UserModel.ClearUserCache(l.ctx, memberUser); clearErr != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user