fix: 付费块文章解锁无响应——unlockPost 守卫误用 canReadPost
付费块文章的整篇是公开的,canReadPost 恒为 true,导致解锁请求被"已有权限"守卫拦截直接跳回文章页,不创建订单。改为按 canReadPaidContent 判断(能否读付费内容),并补回归测试:付费块解锁→创建订单→沙箱支付→[paid] 块可见
This commit is contained in:
@@ -78,8 +78,9 @@ class MembershipController
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
// 已有阅读权限(会员 / 作者 / 已解锁):直接查看文章,避免重复支付
|
||||
if ($this->service->canReadPost($user, $post)) {
|
||||
// 已能读付费内容(会员 / 作者 / 已解锁):直接查看文章,避免重复支付。
|
||||
// 注意:付费块文章的整篇是公开的,不能用 canReadPost 判断(否则永远"已有权限")
|
||||
if ($this->service->canReadPaidContent($user, $post)) {
|
||||
return redirect()->route('posts.show', $post->slug ?? $post->id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user