Created
June 5, 2014 10:14
-
-
Save RodolfoSilva/1f438da56cb55c1eaea0 to your computer and use it in GitHub Desktop.
HOOKS Validação de token
This file contains hidden or 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
<?php | |
$token_list = array('_4as82-6assda79sasg_da7s39sa3f32ar6rta' => true,'s796as7dafsdf67d60s9s_df7das67d-796f' => false); | |
$app->hook( | |
'slim.before.router', | |
function () use ($app, $token_list) { | |
$req = $app->request(); | |
$current_path = $req->getPathInfo(); | |
if (!empty($current_path) && $current_path != '/') { | |
$access_token = $req->get('access_token'); | |
if (!isset($token_list[$access_token]) || $token_list[$access_token] !== true) { | |
$app->render( | |
'default.php', | |
array('message' => 'O token de acesso fornecido é invalido'), | |
400 | |
); | |
$app->stop(); | |
} | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment