diff options
author | Florian Pritz <bluewind@xinu.at> | 2016-09-30 12:01:52 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2016-11-05 19:44:15 +0100 |
commit | 63db15c7d1aad2d115163621e0fa7d88960314ac (patch) | |
tree | c806269d583a0e5133083f9903c6c8b8e4125ac7 | |
parent | 0306ddec3de436b683bc784574d5bf41584f2e14 (diff) |
api/user/create_apikey: Directly log in with username/pw
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | application/controllers/api/v1/user.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php index e96a6c6fb..38247d02c 100644 --- a/application/controllers/api/v1/user.php +++ b/application/controllers/api/v1/user.php @@ -24,7 +24,16 @@ class user extends \controllers\api\api_controller { 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; |