From f595fb2786d884dbaf7ec87d53cee920a0655f0e Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 29 Jul 2015 17:42:48 -0400 Subject: Add first draft of the user api --- app/Api/Auth.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/Api/Auth.php (limited to 'app/Api/Auth.php') diff --git a/app/Api/Auth.php b/app/Api/Auth.php new file mode 100644 index 00000000..9d401746 --- /dev/null +++ b/app/Api/Auth.php @@ -0,0 +1,40 @@ +container['dispatcher']->dispatch('api.bootstrap', new Event); + + if ($username !== 'jsonrpc' && $this->authentication->authenticate($username, $password)) { + $this->checkProcedurePermission(true, $method); + $this->userSession->refresh($this->user->getByUsername($username)); + } + else if ($username === 'jsonrpc' && $password === $this->config->get('api_token')) { + $this->checkProcedurePermission(false, $method); + } + else { + throw new AuthenticationFailure('Wrong credentials'); + } + } +} -- cgit v1.2.3