Welcome Guest, Not a member yet? Register   Sign In
DX Auth - Using Permissions
#1

[eluser]JamesTaylor[/eluser]
I'm using DX Auth for the first time and attempting to setup a mini example for myself to get to grips with it. I have it installed and working with CI2 now and am wanting to implement permissions for the 1st time.

I have created 2 new accounts, the 1st is an admin acc. and the 2nd is a user acc. I have also created 2 additional controllers called 'allow' and 'deny'.

Using the admin acc. i have set the the URI Permissions for the 'user' accounts to include the controller 'allow' by adding \allow\ and saving the update.

my 2 controllers are identical except for their names, here is what i have in them:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Allow extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        
        $this->dx_auth->check_uri_permissions();
    }

    function index()
    {
        $this->load->view('welcome_message');
    }
}

I was expecting that when i logged in with the user account i would be able to view the 'allow page' but not the 'deny page' however i am currently getting the following error message when i view either...

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Allow::$dx_auth

Filename: controllers/allow.php

Line Number: 9

Fatal error: Call to a member function check_uri_permissions() on a non-object in C:\wamp\www\DXAuth-CI2\application\controllers\allow.php on line 9

Line 9 is the '$this->dx_auth->check_uri_permissions();' statement.

Can someone please offer me some help as to what i am doing wrong, i have had a few issues initially with getting DX Auth working with CI2 so i'm not sure if this is just another compatibility issue or I am making a mistake!

Thanks

James
#2

[eluser]predat0r[/eluser]
Did you autoload the lib like 'DX_Auth' and not like 'dx_auth'? The first one works only.
#3

[eluser]JamesTaylor[/eluser]
Thanks predat0r, that was my problem... but i'm straight into another!

when i attempt to access the 'deny' controller as expect i am denied access to hit and am redirected to the url ...index.php/auth/deny - however this brings up a 404 page not found error??
#4

[eluser]predat0r[/eluser]
I'm just guessing, 404 error means - in my opinion - your view isn't there or misspelled or stg, did you do a view for deny?
#5

[eluser]JamesTaylor[/eluser]
Yeah i agree predat0r!

It appears that there is no function 'deny' in the controller 'auth' which comes with DX Auth... seems a bit strange to me, but maybe its an oversight in the library??

If I add the function to the controller I no longer get the 404 page - instead i'm echoing out 'denied' via the function which is working.

Am I missing something here, perhaps in the config of DX Auth or has the deny function just been ommitted by accident from DX Auth?? Surely I can't be the 1st to come across this problem?!!

James
#6

[eluser]predat0r[/eluser]
First, you have to set controller(s) and view(s) that can be see the user.
Then set the permissions.
In the lib DX_Auth is the code where redirects users if they try to go to denied uri

Code:
function deny_access($uri = 'deny')
    {
        $this->ci->load->helper('url');
    
        if ($uri == 'login')
        {
            redirect($this->ci->config->item('DX_login_uri'), 'location');
        }
        else if ($uri == 'banned')
        {
            redirect($this->ci->config->item('DX_banned_uri'), 'location');
        }
        else
        {
            redirect($this->ci->config->item('DX_deny_uri'), 'location');            
        }
        exit;
    }

you can modify in the config file these settings, or if its good, you have to write the cont/view.
For example take the DX_banned_uri config item. Its equal to /auth/banned/. You have to create controller/view for that.




Theme © iAndrew 2016 - Forum software by © MyBB