- Function to store and get worked good

- Token works great
- Session works great
This commit is contained in:
2017-09-05 09:53:52 +07:00
parent 45dbe24da7
commit c64064321e
5 changed files with 70 additions and 35 deletions

View File

@@ -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();
}
}
}