Merge pull request #2270 from int2001/api_auth_fix

Fixes CAT-Update when not logged in
这个提交包含在:
Andreas Kristiansen 2023-07-10 12:12:01 +02:00 提交者 GitHub
当前提交 895ea9b0fa
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 2 个文件被更改,包括 170 次插入144 次删除

查看文件

@ -78,8 +78,20 @@
} }
function json($id) function json($id) {
{
$this->load->model('user_model');
// Check if users logged in
if($this->user_model->validate_session() == 0) {
// user is not logged in
// Return Json data
header('Content-Type: application/json');
echo json_encode(array(
"error" => "not_logged_in"
), JSON_PRETTY_PRINT);
} else {
header('Content-Type: application/json'); header('Content-Type: application/json');
@ -157,6 +169,7 @@
} }
} }
} }
}
function get_mode_designator($frequency) function get_mode_designator($frequency)
{ {

查看文件

@ -1246,8 +1246,21 @@ $(document).on('keypress',function(e) {
"satmode": "S/X", "satmode": "S/X",
"satname": "QO-100" "satname": "QO-100"
"power": "20" "power": "20"
"prop_mode": "SAT" "prop_mode": "SAT",
"error": "not_logged_id" // optional, reserved for errors
} */ } */
if (data.error) {
if (data.error == 'not_logged_in') {
$(".radio_cat_state" ).remove();
if($('.radio_login_error').length == 0) {
$('.qso_panel').prepend('<div class="alert alert-danger radio_login_error" role="alert"><i class="fas fa-broadcast-tower"></i> You\'re not logged it. Please <a href="<?php echo base_url();?>">login</a></div>');
}
}
// Put future Errorhandling here
} else {
if($('.radio_login_error').length != 0) {
$(".radio_login_error" ).remove();
}
$('#frequency').val(data.frequency); $('#frequency').val(data.frequency);
$("#band").val(frequencyToBand(data.frequency)); $("#band").val(frequencyToBand(data.frequency));
if (data.frequency_rx != "") { if (data.frequency_rx != "") {
@ -1303,7 +1316,7 @@ $(document).on('keypress',function(e) {
$('#radio_cat_state').html(text); $('#radio_cat_state').html(text);
} }
} }
}
}); });
} }
}; };