Created
January 19, 2014 21:56
-
-
Save zacharyblank/8511498 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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