e107 icon indicating copy to clipboard operation
e107 copied to clipboard

[Bug]: Admin Area JavaScript Error for Core update

Open Vodhin opened this issue 7 months ago • 0 comments

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

Vodhin avatar Jun 27 '24 16:06 Vodhin