This commit is contained in:
parent
dbcb1fb066
commit
19932bb9f7
@ -181,7 +181,7 @@ jobs:
|
||||
cd ${{ env.DEPLOY_PATH }}
|
||||
|
||||
# 创建/更新环境变量文件
|
||||
echo "PPANEL_SERVER_TAG=${{ env.DOCKER_TAG_SUFFIX }}" > .env
|
||||
# echo "PPANEL_SERVER_TAG=${{ env.DOCKER_TAG_SUFFIX }}" > .env
|
||||
|
||||
# 拉取最新镜像
|
||||
echo "📥 拉取镜像..."
|
||||
|
||||
@ -44,6 +44,9 @@ func (l *DeleteAccountLogic) DeleteAccountAll() (resp *types.DeleteAccountRespon
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "Invalid Access")
|
||||
}
|
||||
|
||||
// 事务前先查出 AuthMethods,用于事务后精确清缓存
|
||||
authMethods, _ := l.svcCtx.UserModel.FindUserAuthMethods(l.ctx, currentUser.Id)
|
||||
|
||||
affectedUserIDs := []int64{currentUser.Id}
|
||||
err = l.svcCtx.UserModel.Transaction(l.ctx, func(tx *gorm.DB) error {
|
||||
familyUserIDs, collectErr := l.collectAffectedFamilyUserIDs(tx, currentUser.Id)
|
||||
@ -56,6 +59,17 @@ func (l *DeleteAccountLogic) DeleteAccountAll() (resp *types.DeleteAccountRespon
|
||||
if removeErr := exitHelper.removeUserFromActiveFamily(tx, currentUser.Id, true); removeErr != nil {
|
||||
return removeErr
|
||||
}
|
||||
|
||||
// 解绑所有登录方式(邮箱、手机等)
|
||||
if err := tx.Where("user_id = ?", currentUser.Id).Delete(&user.AuthMethods{}).Error; err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DatabaseUpdateError), "delete user auth methods failed")
|
||||
}
|
||||
|
||||
// 删除该用户的所有订阅
|
||||
if err := tx.Where("user_id = ?", currentUser.Id).Delete(&user.Subscribe{}).Error; err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DatabaseUpdateError), "delete user subscribes failed")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@ -63,6 +77,25 @@ func (l *DeleteAccountLogic) DeleteAccountAll() (resp *types.DeleteAccountRespon
|
||||
}
|
||||
|
||||
l.clearAllSessions(currentUser.Id)
|
||||
|
||||
// 主动清 auth method 相关缓存(含 email/mobile 等 key),避免缓存未命中时无法生成正确 key
|
||||
if len(authMethods) > 0 {
|
||||
var authCacheKeys []string
|
||||
for _, am := range authMethods {
|
||||
if am.AuthType == "email" && am.AuthIdentifier != "" {
|
||||
authCacheKeys = append(authCacheKeys, fmt.Sprintf("cache:user:email:%s", am.AuthIdentifier))
|
||||
}
|
||||
}
|
||||
if len(authCacheKeys) > 0 {
|
||||
if delErr := l.svcCtx.Redis.Del(l.ctx, authCacheKeys...).Err(); delErr != nil {
|
||||
l.Errorw("clear auth method cache failed",
|
||||
logger.Field("user_id", currentUser.Id),
|
||||
logger.Field("error", delErr.Error()),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if cacheErr := l.clearUserAndSubscribeCaches(affectedUserIDs); cacheErr != nil {
|
||||
l.Errorw("clear user related cache failed",
|
||||
logger.Field("user_id", currentUser.Id),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user