Skip to content

Commit

Permalink
Better error messages in uploader
Browse files Browse the repository at this point in the history
Closes issue #146
  • Loading branch information
hamidsafdari authored and notartom committed Dec 10, 2023
1 parent aad0fea commit 1c0a921
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions application/controllers/public/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,42 @@ function __construct()
ini_set('memory_limit', '128M');

$allowed_groups = array(PERMISSIONS_ADMIN, PERMISSIONS_BCS, PERMISSIONS_MCS, PERMISSIONS_UPLOADER, PERMISSIONS_PLS, PERMISSIONS_READERS);
if (!$this->librivox_auth->has_permission($allowed_groups, $this->data['user_id']))
{
redirect('auth/error_no_permission');
}
$has_group_permission = $this->librivox_auth->has_permission($allowed_groups, $this->data['user_id']);

$ajax_error = NULL;
$redirect_url = NULL;
# First determine the error condition, if any.
if (!$this->ion_auth->logged_in())
{
$ajax_error = "Your session has expired, please login again.";
$redirect_url = "auth/login";
}
else if (!$has_group_permission)
{
$ajax_error = "You don't have permissions for this area.";
$redirect_url = "auth/error_no_permission";
}

# Then, based on the presence of an error condition and whether we're being called by AJAX or not,
# echo or redirect.
if (IS_AJAX and $ajax_error)
{
echo json_encode(
array(
array(
'error' => $ajax_error,
'name' => '',
'size' => 0,
)
)
);
die();
}

if ($redirect_url)
{
redirect($redirect_url);
}

$this->load->helper(array('form', 'url'));

Expand Down

0 comments on commit 1c0a921

Please sign in to comment.