fix: 重置密码忽略租户过滤

This commit is contained in:
2025-12-15 15:27:32 +08:00
parent d2c7e1fb71
commit 2150ae8f8c
3 changed files with 24 additions and 3 deletions

View File

@@ -46,12 +46,11 @@ public sealed class ResetAdminPasswordByTokenCommandHandler(
throw new BusinessException(ErrorCodes.BadRequest, "重置链接无效或已过期");
}
// 3. (空行后) 获取用户(可更新)并写入新密码哈希
var user = await userRepository.GetForUpdateAsync(userId.Value, cancellationToken)
// 3. (空行后) 获取用户(可更新,忽略租户过滤器)并写入新密码哈希
var user = await userRepository.GetForUpdateIgnoringTenantAsync(userId.Value, cancellationToken)
?? throw new BusinessException(ErrorCodes.NotFound, "用户不存在");
user.PasswordHash = passwordHasher.HashPassword(user, password);
await userRepository.SaveChangesAsync(cancellationToken);
}
}