x
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m56s

This commit is contained in:
shanshanzhong 2026-03-06 05:47:47 -08:00
parent dbcb1fb066
commit 19932bb9f7
2 changed files with 34 additions and 1 deletions

View File

@ -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 "📥 拉取镜像..."

View File

@ -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),