消息”:“在邮递员上使用POST请求时,类App \\ Http \\ Requests \\ SignupRequest不存在

时间:2019-06-15 03:56:10

标签: php json laravel postman laravel-5.8

  1. 命名空间App \ Http \ Controllers;

    使用Illuminate \ Http \ Request;使用Illuminate \ Support \ Facades \ Auth; 使用App \ Http \ Controllers \ Controller;

    AuthController类扩展了控制器{

    public function __construct()
    {
        $this->middleware('auth:api', ['except' => ['login']]);
    }
    
    
    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 me()
    {
        return response()->json($this->guard()->user());
    }
    
    
    public function logout()
    {
         $this->guard()->logout();
    
         return response()->json(['message' => 'Successfully logged out']);
    }
    
    
    public function refresh()
    {
        return $this->respondWithToken($this->guard()->refresh());
    }
    
    
    protected function respondWithToken($token)
    {
        return response()->json([
            'access_token' => $token,
            'token_type' => 'bearer',
            'expires_in' => $this->guard()->factory()->getTTL() * 60
        ]);
    }
    
    /**
     * Get the guard to be used during authentication.
     *
     * @return \Illuminate\Contracts\Auth\Guard
     */
    public function guard()
    {
        return Auth::guard();
    } }
    

这是我从jwt官方网站上抄袭的代码,但遇到问题

0 个答案:

没有答案