RouteCollection.php第251行中的MethodNotAllowedHttpException

时间:2017-05-19 12:04:07

标签: jwt laravel-5.4

我使用laravel 5.4 api和jwt token ..当我使用

Route::group(['middleware' => 'auth:api'], function () { Route::get('user',['as' => 'user', 'uses' =>'Auth\LoginController@getUsers']); });

它将返回此错误...这是我的控制器

public function login(Request $request) { $loginData=$request->only('email','password');

if(!isset($loginData['email'])||!isset($loginData['password']))
{
    return response()->json("Email Or Password Incorrect",500);
}
else
{
    $pass=User::where('email','=',$loginData['email'])->first();
    if($pass->users_status !=0)
    {
        if(hash('sha512',$loginData['password'])==$pass->password) {
            $customClaims = ["email"=>$pass->email,"role"=>$pass->users_role];
            $token =JWTAuth::fromUser($pass,$customClaims);
            return response()->json(["msg"=>"login Success!","token"=>$token],200);
        }
        else
        {
            return response()->json("Email Or Password Incorrect",500);
        }
    }
    else
    {
        return response()->json("User Not Active",500);
    }
}

}

public function getUsers() { $token=JWTAuth::parseToken()->toUser(); return response()->json($token,500);

}

我使用邮递员进行测试。登录api也正常工作 而且用户api在没有使用中间件的情况下工作。

0 个答案:

没有答案