diff options
author | Florian Pritz <bluewind@xinu.at> | 2016-09-30 12:01:52 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2016-11-01 17:29:04 +0100 |
commit | 6b3e14281cab40982c6d05ed0856c0447601a3b9 (patch) | |
tree | 0cf8e23ecb47b22f4709936b19057d646ac47f7f /application | |
parent | d407878f9c361a4ae175629ac2f109589352224d (diff) |
api/user/create_apikey: Directly log in with username/pw
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-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; |