summaryrefslogtreecommitdiffstats
path: root/application/controllers/api/v1/user.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-10-07 12:50:18 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-11-01 17:29:04 +0100
commit22ebb1a358dc319ab945ecb9987b6ba6aca441df (patch)
tree5427c3bb2dc7abf4470ccbb3ebf92c12d7739378 /application/controllers/api/v1/user.php
parente83d6beb227aeee9846f220e1fcee5c7abfb3844 (diff)
API: Drop v1
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/api/v1/user.php')
-rw-r--r--application/controllers/api/v1/user.php75
1 files changed, 0 insertions, 75 deletions
diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php
deleted file mode 100644
index 38247d02c..000000000
--- a/application/controllers/api/v1/user.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-/*
- * Copyright 2014 Florian "Bluewind" Pritz <bluewind@server-speed.net>
- *
- * 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 \service\user::apikeys($this->muser->get_userid());
- }
-
- public function create_apikey()
- {
- $username = $this->input->post("username");
- $password = $this->input->post("password");
- if ($username && $password) {
- if (!$this->muser->login($username, $password)) {
- throw new \exceptions\NotAuthenticatedException("user/login-failed", "Login failed");
- }
- }
-
- $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 array(
- "new_key" => $key,
- );
- }
-
- public function delete_apikey()
- {
- $this->muser->require_access("full");
-
- $userid = $this->muser->get_userid();
- $key = $this->input->post("delete_key");
-
- $this->db->where('user', $userid)
- ->where('key', $key)
- ->delete('apikeys');
-
- $affected = $this->db->affected_rows();
-
- assert($affected >= 0 && $affected <= 1);
- if ($affected == 1) {
- return array(
- "deleted_keys" => array(
- $key => array (
- "key" => $key,
- ),
- ),
- );
- } else {
- throw new \exceptions\PublicApiException('user/delete_apikey/failed', 'Apikey deletion failed. Possibly wrong owner.');
- }
- }
-}