From e32f26d048249b84166542d6442efdf202ff44fd Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 23 May 2015 21:44:33 -0400 Subject: API refactoring --- app/Api/Base.php | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 app/Api/Base.php (limited to 'app/Api/Base.php') diff --git a/app/Api/Base.php b/app/Api/Base.php new file mode 100644 index 00000000..e9494b58 --- /dev/null +++ b/app/Api/Base.php @@ -0,0 +1,81 @@ +container = $container; + } + + /** + * Load automatically models + * + * @access public + * @param string $name Model name + * @return mixed + */ + public function __get($name) + { + return $this->container[$name]; + } + + /** + * Check api credentials + * + * @access public + * @param string $username + * @param string $password + * @param string $class + * @param string $method + */ + public function authentication($username, $password, $class, $method) + { + $this->container['dispatcher']->dispatch('api.bootstrap', new Event); + + if (! ($username === 'jsonrpc' && $password === $this->config->get('api_token'))) { + throw new AuthenticationFailure('Wrond credentials'); + } + } +} -- cgit v1.2.3