first
小李世界
4年前
修改理由:
此投稿已在 4年前 合并。
内容修改:
Old | New | Differences |
---|---|---|
1 | ||
1 | ## 确定当前用户是否已经认证 | |
2 | ||
3 | 你可以使用 `Auth` facade 的 `check` 方法来检查用户是否已认证。如果已认证,将会返回 `true`: | |
4 | ||
5 | ``` | |
6 | use Illuminate\Support\Facades\Auth; | |
7 | ||
8 | if (Auth::check()) { | |
9 | // 用户已经登录了... | |
10 | } | |
11 | ``` | |
12 | ||
13 | > 虽然可以使用 `check` 方法确认用户是否被认证,但是在允许用户访问的某些路由 / 控制器之前,通常还是会使用中间件来验证用户是否进行过身份验证。想要了解更多信息,请查看有关 [保护路由](https://learnku.com/docs/laravel/5.8/authentication#protecting-routes) 的文档。 |