【发布时间】:2020-06-26 14:46:10
【问题描述】:
我在尝试通过 Postman 发布 API 以对站点中的用户进行身份验证时遇到错误。
登录功能:
public function login(Request $request)
{
$credentials = $request->only('email', 'password');
if ($token = $this->guard()->attempt($credentials)) {
return $this->respondWithToken($token);
}
return response()->json(['error' => 'Unauthorized'], 401);
}
保护功能
public function guard()
{
return Auth::guard();
}
邮递员显示的错误
"message": "Call to undefined method Tymon\\JWTAuth\\Contracts\\Providers\\Auth::guard()",
"exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
如何解决?
【问题讨论】: