I am get an empty response when I $.ajax to a route that executes the controller below from a cross domain request. When I uncomment the var_dump line I get a response with data otherwise I get a 404 response and the responsejson object is undefined. Any help greatly appreciated. When I access the get equivalent of the same route directly in the browser, I get a valid json response.
<?php
use App\Models\User;
class AuthenticationController extends \BaseController {
public function getLogin() {
return $this->postLogin();
}
public function postLogin() {
$credentials = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
try {
$user = Sentry::authenticate($credentials, false);
if ($user) {
//var_dump(array('flash' => 'Authentication failed'));
//return Response::json(array('flash' => 'Authentication failed'), 401);
return $user->toJson();
}
} catch (Exception $e) {
return Response::json(array('flash' => 'Authentication failed'), 401);
}
}
public function getLogout() {
Sentry::logout();
return Response::json(array('flash' => 'Logged out'), 200);
//return Redirect::route('admin.login');
}
}