[API] Added userid to the API key.
这个提交包含在:
父节点
109683e041
当前提交
30ba927c25
共有 3 个文件被更改,包括 34 次插入 和 10 次删除
|
|
@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['migration_version'] = 75;
|
$config['migration_version'] = 78;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
defined('BASEPATH') or exit('No direct script access allowed');
|
||||||
|
|
||||||
|
class Migration_add_userid_to_api extends CI_Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$fields = array(
|
||||||
|
'user_id BIGINT(20) DEFAULT NULL',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->dbforge->add_column('api', $fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$this->dbforge->drop_column('api', 'user_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,10 +16,12 @@ class API_Model extends CI_Model {
|
||||||
|
|
||||||
// GET API Keys
|
// GET API Keys
|
||||||
function keys() {
|
function keys() {
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
return $this->db->get('api');
|
return $this->db->get('api');
|
||||||
}
|
}
|
||||||
|
|
||||||
function key_description($key) {
|
function key_description($key) {
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$this->db->where('key', $key);
|
$this->db->where('key', $key);
|
||||||
$query = $this->db->get('api');
|
$query = $this->db->get('api');
|
||||||
|
|
||||||
|
|
@ -34,11 +36,11 @@ class API_Model extends CI_Model {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->db->where('key', xss_clean($key));
|
$this->db->where('key', xss_clean($key));
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$this->db->update('api', xss_clean($data));
|
$this->db->update('api', xss_clean($data));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function country_worked($dxcc_num, $band, $mode){
|
function country_worked($dxcc_num, $band, $mode){
|
||||||
|
|
||||||
if($band == "all") {
|
if($band == "all") {
|
||||||
|
|
@ -93,6 +95,7 @@ class API_Model extends CI_Model {
|
||||||
|
|
||||||
|
|
||||||
function delete_key($key) {
|
function delete_key($key) {
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$this->db->where('key', xss_clean($key));
|
$this->db->where('key', xss_clean($key));
|
||||||
$this->db->delete('api');
|
$this->db->delete('api');
|
||||||
}
|
}
|
||||||
|
|
@ -109,6 +112,8 @@ class API_Model extends CI_Model {
|
||||||
// Set API key to active
|
// Set API key to active
|
||||||
$data['status'] = "active";
|
$data['status'] = "active";
|
||||||
|
|
||||||
|
$data['user_id'] = $this->session->userdata('user_id');
|
||||||
|
|
||||||
$this->db->insert('api', $data);
|
$this->db->insert('api', $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用