Welcome Guest, Not a member yet? Register   Sign In
Updating DX Auth
#1

[eluser]austintbiggs[/eluser]
I've recently taken on the task of updating a library to allow it to run on CI 2.0.2 [it was written for CI 1.7.0].

From what I've gathered for controllers and models I just need to add the prefix 'CI_' which I've done. what other changes would effect the code that I should watch out for / modify?

I keep receiving the same error
Quote:Fatal error: Call to undefined method CI_Controller::CI_Controller() in /controllers/auth.php on line 12

auth.php
Code:
<?php
class Auth extends CI_Controller
{
    // Used for registering and changing password form validation
    var $min_username = 4;
    var $max_username = 20;
    var $min_password = 4;
    var $max_password = 20;

    public function Auth()
    {
        parent::CI_Controller();
        
        $this->load->library('Form_validation');
        $this->load->library('DX_Auth');            
        
        $this->load->helper('url');
        $this->load->helper('form');
    }
    
    public function index()
    {
        $this->login();
    }
    
    /* Callback function */
    
    public function username_check($username)
    {
        $result = $this->dx_auth->is_username_available($username);
        if ( ! $result)
        {
            $this->form_validation->set_message('username_check', 'Username already exist. Please choose another username.');
        }
                
        return $result;
    }
...

Any and all help is appreciated! [:
#2

[eluser]Nick_MyShuitings[/eluser]
Update 10/11/2010: Remember to do this for Controllers too. Instead of Foo extends Controller, you must now write Foo extends CI_Controller and all parent::Controller() calls must be changed to parent::__construct()!

From http://philsturgeon.co.uk/news/2010/05/u...gniter-2.0

That should fix that error at least.
#3

[eluser]austintbiggs[/eluser]
Thanks, that fixed everything!
#4

[eluser]k2zs[/eluser]
I'm getting this error after fixing the above mentioned:

Fatal error: Call to undefined method CI_Loader::plugin() in /srv/www/htdocs/staging/staging.nyqp.org/application/libraries/DX_Auth.php on line 1233

I copied the "plugins" directory to my application folder but I believe CI 2.0 no longer supports plugins, where should the plugin go?
#5

[eluser]Nick_MyShuitings[/eluser]
read the link I posted above for Phil... plugins -> helpers with some renaming to do.
#6

[eluser]k2zs[/eluser]
Well,

I had it working but it's not that great of an app. I was able to log in once and tried setting custom permissions but they always reported that admin had no permissions. When I did an "/auth/logout/" I can no longer log in....

Is there an authentication library that works well with CI 2.0.2?
#7

[eluser]InsiteFX[/eluser]
Change all your Constructors.
Code:
// wrong!
    public function Auth()
    {
        parent::CI_Controller();
        
        $this->load->library('Form_validation');
        $this->load->library('DX_Auth');            
        
        $this->load->helper('url');
        $this->load->helper('form');
    }
    
// should be like this now!
    public function __construct()
    {
        parent::__construct();
        
        $this->load->library('Form_validation');
        $this->load->library('DX_Auth');            
        
        $this->load->helper('url');
        $this->load->helper('form');
    }

InsiteFX
#8

[eluser]Nick_MyShuitings[/eluser]
Tank Auth runs out of the box. I'm running a heavily customized version of Tank myself on all my projects.
#9

[eluser]k2zs[/eluser]
[quote author="InsiteFX" date="1303077672"]Change all your Constructors.
Code:
// wrong!
    public function Auth()
    {
        parent::CI_Controller();
        
        $this->load->library('Form_validation');
        $this->load->library('DX_Auth');            
        
        $this->load->helper('url');
        $this->load->helper('form');
    }
    
// should be like this now!
    public function __construct()
    {
        parent::__construct();
        
        $this->load->library('Form_validation');
        $this->load->library('DX_Auth');            
        
        $this->load->helper('url');
        $this->load->helper('form');
    }

InsiteFX[/quote]

Did all that and like I said I had it working for a short time until I logged out and tried logging back in. Now it won't accept the default password...

I did try editing roles and checked "edit" and "delete" for "admin" which weren't checked by default.
#10

[eluser]k2zs[/eluser]
[quote author="Nick_MyShuitings" date="1303078071"]Tank Auth runs out of the box. I'm running a heavily customized version of Tank myself on all my projects.[/quote]

Thanks,

I think I'll give that a try




Theme © iAndrew 2016 - Forum software by © MyBB