tmaiaroto/li3_access — Issue #18: Optional/boolean route parameters not matched
Author: kevmo314
Created: 2012-01-29 09:17:21+00:00
State: open

I have an admin route and sometimes the admin param isn't specified (admin = null vs admin = true) in the route. With AuthRbac, this causes an issue when parsing the match. My fix is as follows but I haven't thoroughly tested it:

Line 147 AuthRbac.php, change

if (!$exists_in_request || $value !== Inflector::underscore($request->params[$type])) {
return false;
}

to:

if($value == null && !$exists_in_request) {
continue;
}
if(!$exists_in_request || $value !== (is_string($request->params[$type]) ? Inflector::underscore($request->params[$type]) : $request->params[$type])) {
return false;
}

I didn't create a pull request because I also want to verify that there isn't an alternate way of doing this that I haven't realized?