Enhance: plans index show safe back link
This commit is contained in:
@@ -29,6 +29,16 @@
|
|||||||
<div class="card mb-20">
|
<div class="card mb-20">
|
||||||
<p class="muted muted-tight">这里是总台视角的套餐目录页,用于沉淀平台可售卖的标准能力包。</p>
|
<p class="muted muted-tight">这里是总台视角的套餐目录页,用于沉淀平台可售卖的标准能力包。</p>
|
||||||
<p class="muted">当前阶段先完成套餐主数据可见、可筛与口径收拢,后续再接授权项、售价规则与上下架动作。</p>
|
<p class="muted">当前阶段先完成套餐主数据可见、可筛与口径收拢,后续再接授权项、售价规则与上下架动作。</p>
|
||||||
|
|
||||||
|
@php
|
||||||
|
$incomingBack = (string) request()->query('back', '');
|
||||||
|
$safeBack = str_starts_with($incomingBack, '/') ? $incomingBack : '';
|
||||||
|
@endphp
|
||||||
|
@if($safeBack)
|
||||||
|
<div class="mt-10">
|
||||||
|
<a href="{{ $safeBack }}" class="muted">← 返回上一页(保留上下文)</a>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card mb-20">
|
<div class="card mb-20">
|
||||||
|
|||||||
40
tests/Feature/AdminPlanIndexBackLinkTest.php
Normal file
40
tests/Feature/AdminPlanIndexBackLinkTest.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlanIndexBackLinkTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->seed();
|
||||||
|
|
||||||
|
$this->post('/admin/login', [
|
||||||
|
'email' => 'platform.admin@demo.local',
|
||||||
|
'password' => 'Platform@123456',
|
||||||
|
])->assertRedirect('/admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_should_show_safe_back_link_when_back_is_relative_path(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$this->get('/admin/plans?status=active&back=' . urlencode('/admin/site-subscriptions?status=activated'))
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('返回上一页(保留上下文)')
|
||||||
|
->assertSee('href="/admin/site-subscriptions?status=activated"', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_should_not_show_back_link_when_back_is_external_url(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$this->get('/admin/plans?back=' . urlencode('https://evil.example.com/'))
|
||||||
|
->assertOk()
|
||||||
|
->assertDontSee('返回上一页(保留上下文)');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user