# 修改路由可以访问签名链接

既然生成了签名链接,那么就需要防止未签名的访问,最简单的办法是使用签名中间件,如果它不在app/http/kernel.php中的$routemiddleware数组中，则应该在light\routing\middleware\validatesignature中

```php
Route::get('invitations/{invitation}/{answer}', 'InvitationController')
    ->name('invitations')
    ->middleware('signed');
```

如果你愿意,你可以调用请求对象的hasValidSignature()方法,代替使用signed中间件

```php
class InvitationController
{
    public function __invoke(Invitation $invitation, $answer, Request $request)
    {
        if (!$request->hasValidSignature()) {
            abort(403);
        }
//
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liseen315.gitbook.io/laravel/lu-you-yu-kong-zhi-qi/lu-you-qian-ming/xiu-gai-lu-you-ke-yi-fang-wen-qian-ming-lian-jie.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
