From 8fd7c6c2ab80240ab1d163c9a4134822c7524144 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 11 Jan 2015 01:40:07 +0100 Subject: add initial user api Signed-off-by: Florian Pritz --- application/controllers/api/v1/user.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 application/controllers/api/v1/user.php (limited to 'application/controllers/api/v1/user.php') diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php new file mode 100644 index 000000000..831fdb883 --- /dev/null +++ b/application/controllers/api/v1/user.php @@ -0,0 +1,24 @@ + + * + * Licensed under AGPLv3 + * (see COPYING for full license text) + * + */ +namespace controllers\api\v1; + +class user extends \controllers\api\api_controller { + public function __construct() + { + parent::__construct(); + + $this->load->model('muser'); + } + + public function apikeys() + { + $this->muser->require_access("full"); + return send_json_reply(\service\user::apikeys($this->muser->get_userid())); + } +} -- cgit v1.2.3-24-g4f1b From 0bed4fd5c9f67b60173df6638dc524d7b833c4e1 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 11 Jan 2015 23:35:46 +0100 Subject: add some TODOs Signed-off-by: Florian Pritz --- application/controllers/api/v1/user.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'application/controllers/api/v1/user.php') diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php index 831fdb883..4c2e5345d 100644 --- a/application/controllers/api/v1/user.php +++ b/application/controllers/api/v1/user.php @@ -21,4 +21,9 @@ class user extends \controllers\api\api_controller { $this->muser->require_access("full"); return send_json_reply(\service\user::apikeys($this->muser->get_userid())); } + + public function create_apikey() + { + // TODO: implement + } } -- cgit v1.2.3-24-g4f1b From e2c2740365b1f25beca1e174c8c5bda2950b7466 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 3 Feb 2015 00:44:46 +0100 Subject: implement api/user/create_apikey Signed-off-by: Florian Pritz --- application/controllers/api/v1/user.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'application/controllers/api/v1/user.php') diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php index 4c2e5345d..39c833d86 100644 --- a/application/controllers/api/v1/user.php +++ b/application/controllers/api/v1/user.php @@ -21,9 +21,19 @@ class user extends \controllers\api\api_controller { $this->muser->require_access("full"); return send_json_reply(\service\user::apikeys($this->muser->get_userid())); } - + public function create_apikey() { - // TODO: implement + $this->muser->require_access("full"); + $userid = $this->muser->get_userid(); + $comment = $this->input->post("comment"); + $comment = $comment === false ? "" : $comment; + $access_level = $this->input->post("access_level"); + + $key = \service\user::create_apikey($userid, $comment, $access_level); + + return send_json_reply(array( + "new_key" => $key, + )); } } -- cgit v1.2.3-24-g4f1b From 6816970229c6d0bd46ba46ecd70199c0687952da Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 3 Feb 2015 11:12:01 +0100 Subject: api: handle json reply in api controller Signed-off-by: Florian Pritz --- application/controllers/api/v1/user.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'application/controllers/api/v1/user.php') diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php index 39c833d86..e49b7c657 100644 --- a/application/controllers/api/v1/user.php +++ b/application/controllers/api/v1/user.php @@ -19,7 +19,7 @@ class user extends \controllers\api\api_controller { public function apikeys() { $this->muser->require_access("full"); - return send_json_reply(\service\user::apikeys($this->muser->get_userid())); + return \service\user::apikeys($this->muser->get_userid()); } public function create_apikey() @@ -32,8 +32,8 @@ class user extends \controllers\api\api_controller { $key = \service\user::create_apikey($userid, $comment, $access_level); - return send_json_reply(array( + return array( "new_key" => $key, - )); + ); } } -- cgit v1.2.3-24-g4f1b