Skip to content

Commit 5da2df3

Browse files
author
Phil Sturgeon
committed
Added some status = 0/1 to the main REST_Controller responses.
1 parent 4097491 commit 5da2df3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

application/controllers/api/keys.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,9 @@ public function index_delete()
9292
*/
9393
public function level_post()
9494
{
95-
$this->load->helper('security');
96-
9795
$key = $this->post('key');
9896
$new_level = $this->post('level');
99-
97+
10098
// Does this key even exist?
10199
if ( ! self::_key_exists($key))
102100
{
@@ -107,7 +105,7 @@ public function level_post()
107105
// Update the key level
108106
if (self::_update_key($key, array('level' => $new_level)))
109107
{
110-
$this->response(array('status' => 1, 'success' => $this->rest->db->last_query()), 200); // 201 = Created
108+
$this->response(array('status' => 1, 'success' => 'Key was updated.'), 200); // 201 = Created
111109
}
112110

113111
else
@@ -128,8 +126,6 @@ public function level_post()
128126
*/
129127
public function regenerate_post()
130128
{
131-
$this->load->helper('security');
132-
133129
$old_key = $this->post('key');
134130
$key_details = self::_get_key($old_key);
135131

@@ -164,6 +160,8 @@ public function regenerate_post()
164160

165161
private function _generate_key()
166162
{
163+
$this->load->helper('security');
164+
167165
do
168166
{
169167
$salt = dohash(time().mt_rand());

application/libraries/REST_Controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function _remap($object_called)
112112
// Their key is shit
113113
if ( ! $this->_detect_api_key())
114114
{
115-
$this->response(array('error' => 'Invalid API Key.'), 403);
115+
$this->response(array('status' => 0, 'error' => 'Invalid API Key.'), 403);
116116
return;
117117
}
118118

@@ -128,7 +128,7 @@ function _remap($object_called)
128128
// They don't have good enough perms
129129
if ( ! $authorized)
130130
{
131-
$this->response(array('error' => 'This API key does not have enough permissions.'), 401);
131+
$this->response(array('status' => 0, 'error' => 'This API key does not have enough permissions.'), 401);
132132
return;
133133
}
134134
}

0 commit comments

Comments
 (0)