PHP开发Swagger登录认证报错:Cannot access offset of type string on string (0)
PHP登录认证Swagger测试报错:Cannot access offset of type string on string (0)
Cannot access offset of type string on string (0)
我正在用PHP开发Web应用,实现登录认证功能时,通过Swagger测试出现上述报错。已排查服务层和数据访问层的所有方法,仍未解决,使用var_dump()调试时同样触发该错误。
以下是路由代码:
/** * @OA\Post( * path="/auth/login", * tags={"auth"}, * summary="Login to system using email and password", * @OA\Response( * response=200, * description="User data and JWT" * ), * @OA\RequestBody( * description="Credentials", * @OA\JsonContent( * required={"email","pwd"}, * @OA\Property(property="email", type="string", example="example@example.com", description="User email address"), * @OA\Property(property="pwd", type="string", example="some_password", description="User password") * ) * ) * ) */ Flight::route('POST /login', function() { $payload = Flight::request()->data->getData(); var_dump($payload); $user = Flight::get('auth_service')->get_user_by_email($payload['email']); var_dump($user); if(!$user || !password_verify($payload['pwd'], $user['pwd'])) Flight::halt(500, "Invalid username or password"); unset($user['pwd']); });
内容的提问来源于stack exchange,提问作者Amir Bašović
相关产品推荐
相关产品推荐

