Skip to content

Instantly share code, notes, and snippets.

@zacharyblank
Created January 19, 2014 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zacharyblank/8511498 to your computer and use it in GitHub Desktop.
Save zacharyblank/8511498 to your computer and use it in GitHub Desktop.
App::before(function($request)
{
header('Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS');
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
exit;
}
// Some endpoints have optional user proporties. If an access_token is passed
// Check it's validity and process the additional properties
$server = new League\OAuth2\Server\Resource(new SessionModel);
try {
$server->isValid();
User::setCurrentUser($server->getOwnerId());
} catch (Exception $e) {}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment