- Function to store and get worked good
- Token works great - Session works great
This commit is contained in:
@@ -66,11 +66,29 @@ class Router
|
||||
$action = $this->convertToCamelCaps($action);
|
||||
|
||||
if (is_callable([$object, $action])) {
|
||||
if (array_key_exists('id', $this->params)) {
|
||||
$var = $this->params['id'];
|
||||
return $object->$action($var);
|
||||
// Check if there's input to the current page
|
||||
if (Input::exists('post')) {
|
||||
$var = $_POST;
|
||||
// Check the token
|
||||
if (Token::check($var['_token'])) {
|
||||
// Get the method
|
||||
$action = $var['_method'];
|
||||
} else {
|
||||
// Token invalid
|
||||
$flash = Session::flash('info', 'Token invalid, try again');
|
||||
die($flash);
|
||||
}
|
||||
unset($var['_token']);
|
||||
unset($var['_method']);
|
||||
}
|
||||
if (array_key_exists('id', $this->params)) {
|
||||
$var[] = $this->params['id'];
|
||||
}
|
||||
if (isset($var)) {
|
||||
return $object->$action($var);
|
||||
} else {
|
||||
return $object->$action();
|
||||
}
|
||||
return $object->$action();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user