Skip to content

Commit

Permalink
Restrict backend to super users and frontend to registered users as d…
Browse files Browse the repository at this point in the history
…iscussed in #11 (#13)
  • Loading branch information
zero-24 authored and Michael Babker committed May 3, 2018
1 parent 4b0f1c1 commit 8c033ce
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 23 deletions.
7 changes: 0 additions & 7 deletions administrator/components/com_privacy/access.xml

This file was deleted.

14 changes: 0 additions & 14 deletions administrator/components/com_privacy/config.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
filter="rules"
validate="rules"
component="com_privacy"
section="component" />
</fieldset>
</config>
3 changes: 2 additions & 1 deletion administrator/components/com_privacy/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

defined('_JEXEC') or die;

if (!JFactory::getUser()->authorise('core.manage', 'com_privacy'))
// Only super user can access here
if (!JFactory::getUser()->authorise('core.admin'))
{
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
Expand Down
1 change: 0 additions & 1 deletion administrator/components/com_privacy/privacy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<description>COM_PRIVACY_XML_DESCRIPTION</description>
<administration>
<files folder="admin">
<filename>access.xml</filename>
<filename>config.xml</filename>
<filename>controller.php</filename>
<filename>privacy.php</filename>
Expand Down
6 changes: 6 additions & 0 deletions components/com_privacy/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

defined('_JEXEC') or die;

// Only authenticated user have access
if (JFactory::getUser()->guest)
{
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}

$controller = JControllerLegacy::getInstance('Privacy');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

0 comments on commit 8c033ce

Please sign in to comment.