/**
  * Check the results of the authorization attempt, and return the appropriate response.
  *
  * @param JsonResponse|Response $auth
  * @return JsonResponse|Response
  */
 private function checkAuth($auth)
 {
     $data = json_decode($auth->content());
     $response = '';
     if (isset($data->error)) {
         // An error was returned, so let's send it back to the user
         $errors = new MessageBag([$data->error => [$data->message]]);
         $response = redirect()->back()->withErrors($errors);
     } elseif (isset($data->jwtoken)) {
         // A JWT was returned, so let's use it to run the postLogin function
         $response = $this->userAuth->postLogin($data->jwtoken);
     } else {
         // Something is awry, so let's abort
         abort(501);
     }
     return $response;
 }