# Blade认证指令

如果你想检查用户是否认证过，不在路由层而是在视图上，你可以使用@auth和@guest（如示例9-10）

{% code title="Example 9-10. Checking a user’s authentification status in templates" %}

```
@auth
// The user is authenticated
@endauth
@guest
// The user is not authenticated
@endguest
```

{% endcode %}

你还可以给两个方法传递守护名作为参数来执行守护,如示例9-11

{% code title="Example 9-11. Checking a specific auth guard’s authentification in templates" %}

```
@auth('trainees')
// The user is authenticated
@endauth
@guest('trainees')
// The user is not authenticated
@endguest
```

{% endcode %}


---

# 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/yong-hu-ren-zheng-yu-shou-quan/blade-ren-zheng-zhi-ling.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.
