You can now delete API keys via /api/help

这个提交包含在:
Peter Goodhall 2019-06-21 21:33:21 +01:00
父节点 caf43f2259
当前提交 d05717c1e6
共有 3 个文件被更改,包括 23 次插入5 次删除

查看文件

@ -69,6 +69,20 @@ class API extends CI_Controller {
redirect('api/help');
}
function delete($key) {
$this->load->model('user_model');
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$this->load->model('api_model');
$this->api_model->delete_key($key);
$this->session->set_flashdata('notice', 'API Key <b>'.$key."</b> has been deleted");
redirect('api/help');
}
// Example of authing
function auth($key) {
$this->load->model('api_model');

查看文件

@ -20,7 +20,7 @@ class API_Model extends CI_Model {
}
function delete_key($key) {
$this->db->where('id', $key);
$this->db->where('key', $key);
$this->db->delete('api');
}
// Generate API Key

查看文件

@ -2,9 +2,9 @@
<br>
<?php if($this->session->flashdata('notice')) { ?>
<div id="message" >
<?php echo $this->session->flashdata('notice'); ?>
</div>
<div class="alert alert-success" role="alert">
<?php echo $this->session->flashdata('notice'); ?>
</div>
<?php } ?>
<div class="card">
@ -43,7 +43,11 @@
?>
</td>
<td><span class="badge badge-pill badge-light"><?php echo ucfirst($row->status); ?></span> <a href="<?php echo site_url('api/auth/'.$row->key); ?>" target="_blank" class="btn btn-primary btn-sm">Test</td>
<td><span class="badge badge-pill badge-light"><?php echo ucfirst($row->status); ?></span>
<a href="<?php echo site_url('api/auth/'.$row->key); ?>" target="_blank" class="btn btn-primary btn-sm">Test</a>
<a href="<?php echo site_url('api/delete/'.$row->key); ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete API Key <?php echo $row->key; ?>?');">Delete</a>
</td>
</tr>
<?php } ?>