Permalink
Browse files

Added Request and Response arguments to the authorization callback

  • Loading branch information...
dannykopping committed Dec 18, 2012
1 parent d2c4624 commit 443fb39b8b15841be018ea8a4af6276bda76bcec
Showing with 12 additions and 2 deletions.
  1. +7 −2 Spore/Auth/AccessController.php
  2. +5 −0 Spore/ReST/AutoRoute/Router.php
@@ -54,6 +54,10 @@ public function routesReadyHandler($routes)
public function checkAuthorizationForRoute($route)
{
$route = $this->getSlimInstance()->router()->current();
$router = $this->getSlimInstance()->router();
$params = $route->getParams();
list($request, $response) = $router->getRequestAndResponseObjects($route, $params);
$callable = $route->getCallable();
$authCallback = self::getAuthorizationCallback();
@@ -80,7 +84,8 @@ public function checkAuthorizationForRoute($route)
if (empty($authorizedUsers))
return;
$authorized = call_user_func_array(self::getAuthorizationCallback(), array($authorizedUsers));
$authorized = call_user_func_array(self::getAuthorizationCallback(),
array($authorizedUsers, $request, $response));
// if the defined role is not authorized, call the "authorization failed" handler
if (!$authorized)
@@ -115,4 +120,4 @@ public static function getAuthorizationCallback()
}
?>
?>
@@ -204,6 +204,11 @@ private function getResponseData()
return $resp;
}
public function getRequestAndResponseObjects($route, $params)
{
return array($this->getRequestData($route, $params), $this->getResponseData());
}
/**
* If a @template annotation has been defined, this function will return the output
* of Slim's parsing of a template, if the correct @render annotation has been specified

0 comments on commit 443fb39

Please sign in to comment.