ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

DX Auth 1.0.6 (Authentication library)

December 01, 2008 6:14am

Subscribe [160]
  • #166 / Dec 15, 2008 7:03pm

    Paul Apostol

    43 posts

    Hello,
    FYK
    If I’m submitting twice the custom_permissions form without changing data the rows in the tables permissions are duplicating (insert instead update). affected_rows always return 0. I think is a CI bug.
    Paul

  • #167 / Dec 15, 2008 9:35pm

    dexcell

    142 posts

    A small remark for this wonderful library:

    Using DX Auth in a project of mine. After uploading the project to my webserver I kept on getting an error message saying dx_auth couldn’t be loaded. Eventually I found out that the capitalized name of the file ‘DX_Auth.php’ was causing the problem.

    I suppose some webservers are case-sensitive while others are not. A small suggestion from me would be to rename the files to Dx_auth.php/Dx_auth_event.php to prevent this error from occuring when run on case-sensitive webservers.

    If i’m not mistaken, it was fixed in 1.0.2.

  • #168 / Dec 15, 2008 9:39pm

    dexcell

    142 posts

    Great Lib. One thing though… After a successful login as a normal user, if I go to the backend’s url, it throws an error. Users shouldn’t know the url to your backend anyway, but just an fyi…

    Btw, do you mean the user manually typed the url?
    Yes, the user is redirected into deny URI that specified in DX Auth config.

    A PHP Error was encountered

    Severity: Warning

    Message: in_array() [function.in-array]: Wrong datatype for second argument

    Filename: libraries/DX_Auth.php

    Line Number: 172

    Can you specify when you get this function error?

  • #169 / Dec 15, 2008 9:41pm

    dexcell

    142 posts

    Hello,
    FYK
    If I’m submitting twice the custom_permissions form without changing data the rows in the tables permissions are duplicating (insert instead update). affected_rows always return 0. I think is a CI bug.
    Paul

    Thank you. You are correct.

    Here is the quick fix (in models/dx_auth/permissions.php)

    function set_permission($role_id, $data, $auto_create = TRUE)
        {                
            if ($auto_create)
            {            
                $this->db->select('1', FALSE);
                $this->db->where('role_id', $role_id);
                $query = $this->db->get($this->_table);
                
                // Check if role_id exist
                if ($query->num_rows() == 0)
                {
                    // Create permission
                    $query = $this->create_permission($role_id, $data);
                }
                else
                {
                    // Update permission
                    $this->db->where('role_id', $role_id);
                    $query = $this->db->update($this->_table, $data);
                }
            }
            else
            {
                // Update permission
                $this->db->where('role_id', $role_id);
                $query = $this->db->update($this->_table, $data);
            }
            
            return $query;
        }
  • #170 / Dec 16, 2008 1:51am

    Iverson

    153 posts

    Can you specify when you get this function error?

    That error occurs during the situation I initially described.

    -I log in as a user
    -Type in the url to the backend
    -Throws the wrong datatype error

  • #171 / Dec 16, 2008 2:52am

    dexcell

    142 posts

    Can you specify when you get this function error?

    That error occurs during the situation I initially described.

    -I log in as a user
    -Type in the url to the backend
    -Throws the wrong datatype error

    Thanks, but i cannot produce the error.

    But i think there is big probability, it’s happened at check_uri_permisisons() function when calling

    if ($this->_array_in_array(array(’/’, $controller, $action), $allowed_uris))

    [line 506 in libraries/DX_Auth.php]

    Maybe $allowed_uris = NULL ? Can you help me do some print_r or something to check the $allowed_uris value.

  • #172 / Dec 16, 2008 4:05am

    Iverson

    153 posts

    Yeah I’m not sure what’s going on. Don’t really feel like troubleshooting so I’ll leave it as it is. Like I said, I’ll be the only one logging into the backend. On another note, when logging out, since you’re only sending a message ($data[‘auth_message’]), most browswers load the cached version of the page, resulting in any login data that was on the page to stay visible. For instance, I show the username and last login on a main page. After clicking logout and loading the example logout function you used, the message shows up that I’m logged out, but the user info still shows. A simple fix was to add

    $this->dx_auth->logout();
    redirect('', 'refresh');
  • #173 / Dec 16, 2008 4:06am

    Berserk

    41 posts

    greats !!! 😊

    can you zip your document ? i want to download to view offline like CI’s doc :D

  • #174 / Dec 16, 2008 6:41am

    Iverson

    153 posts

    So there’s been talk about the config vars being static. This is probably my biggest problem with dx auth(Other than that, it’s by far the best CI lib for authentication I’ve used thus far. Thanks dexcell). If anybody’s interested, I made some mos to the library and created a dx_auth_config table. All the variables get set from the value in the database except the views. I figured there wasn’t really a dire need to be able to dynamically change these so they’re still in dx_auth.php in application/config. I’ve attached the sql file. All you have to do is import it.

    Changes in DX_Auth.php

    Include this line with the class variables:

    var $_config_table = 'dx_auth_config';

    This is the new _init() function:

    function _init()
        {
            // When we load this library, auto Login any returning users
            $this->autologin();
            
            // Init helper config variable
            
    /***********    Start Modification    ************************
    Modification by Iverson
    <a href="http://ellislab.com/forums/member/71157/">http://ellislab.com/forums/member/71157/</a>
    12/16/2008
    ***********************************************************/
    $get_config_vars = $this->ci->db->query('SELECT field, value FROM ' . $this->_config_table);
    
    foreach ($get_config_vars->result() as $row)
    {
        $field = $row->field;
        // Models access the config variable so we'll set the config var it in here to not cause any problems!
        $this->ci->config->set_item($field, $row->value);
        
        // Set this class' variables as well
        $this->$field = $row->value;
    }
    
    /************    End Modification    **********************/
            
            // Forms view
            $this->login_view = $this->ci->config->item('DX_login_view');
            $this->register_view = $this->ci->config->item('DX_register_view');
            $this->forgot_password_view = $this->ci->config->item('DX_forgot_password_view');
            $this->change_password_view = $this->ci->config->item('DX_change_password_view');
            $this->cancel_account_view = $this->ci->config->item('DX_cancel_account_view');
            
            // Pages view
            $this->deny_view = $this->ci->config->item('DX_deny_view');
            $this->banned_view = $this->ci->config->item('DX_banned_view');
            $this->logged_in_view = $this->ci->config->item('DX_logged_in_view');
            $this->logout_view = $this->ci->config->item('DX_logout_view');        
            
            $this->register_success_view = $this->ci->config->item('DX_register_success_view');
            $this->activate_success_view = $this->ci->config->item('DX_activate_success_view');
            $this->forgot_password_success_view = $this->ci->config->item('DX_forgot_password_success_view');
            $this->reset_password_success_view = $this->ci->config->item('DX_reset_password_success_view');
            $this->change_password_success_view = $this->ci->config->item('DX_change_password_success_view');
            
            $this->register_disabled_view = $this->ci->config->item('DX_register_disabled_view');
            $this->activate_failed_view = $this->ci->config->item('DX_activate_failed_view');
            $this->reset_password_failed_view = $this->ci->config->item('DX_reset_password_failed_view');
        }


    Changes in application/config/dx_auth.php
    Simply comment out all variables except the view variables. Or you can download the one created. I left all the comments in because it’s really well documented


    If anyone disagrees with this, let me know why so I’ll know if I need to revert back to static vars. The main benefit of this is that the admin panel I’m creating will be able to change all my authentication settings from a GUI instead of having to edit a static file.

  • #175 / Dec 16, 2008 10:13am

    humugus

    12 posts

    thank you very much for a great library, which by the way was implemented very easily to my project although i’m a newbie in CI and PHP programming 😊

    i have a question, as i could not find the answer in all those pages of the thread :

    the database has already 2 users registered : admin (id 1) and user(id 2)
    which is the password for the admin ?

  • #176 / Dec 16, 2008 10:15am

    Iverson

    153 posts

    the database has already 2 users registered : admin (id 1) and user(id 2)
    which is the password for the admin ?

    I had the same problem. The info is at
    http://dexcell.shinsengumiteam.com/dx_auth/installation/schema.html

  • #177 / Dec 16, 2008 10:20am

    humugus

    12 posts

    thank you very much for the fast reply, i should have noticed it myself :?
    but using the library for just a few hours i was thrilled that i got a grasp on it although i have not read everything !!

  • #178 / Dec 16, 2008 10:22am

    Iverson

    153 posts

    thank you very much for the fast reply, i should have noticed it myself :?
    but using the library for just a few hours i was thrilled that i got a grasp on it although i have not read everything !!

    Yeah, CI forums have the fastest response time I’ve seen dealing with PHP. That’s why we’re always on it… 😝

  • #179 / Dec 16, 2008 10:29am

    humugus

    12 posts

    hmm, i cannot login ...
    could it be the encryption_key ??
    ———-

    EDIT : yes, i deleted my encryption key from CI config and was able to login :D

  • #180 / Dec 16, 2008 11:04am

    dexcell

    142 posts

    Thanks Iverson,

    In my opinion, i think it’s better creating a parser function to parse DX Auth config file,
    then display it to GUI page.
    Then if you save it you can create new config file, overwrite the old config.

    The benefit if you are creating the parser you can parse practically any static config (not only DX Auth),
    and display it to your GUI page.

    This way also you don’t need to edit DX_Auth core.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases