e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
318 stars 212 forks source link

[Bug]: Admin Area JavaScript Error for Core update #5286

Open Vodhin opened 4 days ago

Vodhin commented 4 days ago

What e107 version are you using?

v2.3.3

Bug description

Looks like admin.php is not returning a proper JSON response for Admin users who are NOT Main Admin and may not have permissions for the update function.

JavaScript Console Error

VM6027:1 Uncaught SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON
    at JSON.parse (<anonymous>)
    at n.parseJSON (jquery.min.js:4:6340)
    at Object.success (admin.php:104:22)
    at i (jquery.min.js:2:27151)
    at Object.fireWith [as resolveWith] (jquery.min.js:2:27914)
    at z (jquery.min.js:4:12059)
    at XMLHttpRequest.<anonymous> (jquery.min.js:4:15619)

From admin.php:

$('#e-admin-core-update').html('<i title="Checking for updates" class="fa fa-spinner fa-spin"></i>');
                $.get('../e107_admin/admin.php?mode=core&type=update', function( data ) {

                var res = $.parseJSON(data);

                if(res === true)
                {
                    $('#e-admin-core-update').html('<span class="text-info"><i class="fa fa-database"></i></span>');

                     $('[data-toggle="popover"]').popover('show');
                     $('.popover').on('click', function() 
                     {
                         $('[data-toggle="popover"]').popover('hide');
                    });
                }
                else
                {
                    // Hide li element.
                    $('#e-admin-core-update').parent().hide();
                }

            });

How to reproduce

Log in as and Admin without permissions for updates and go to Admin Area,

Expected behavior

Not fail.

What browser(s) are you seeing the problem on?

Chrome / Brave

PHP Version

8.2.2