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]
  • #586 / Jul 14, 2010 12:20pm

    nomikos3

    33 posts

    You are welcome. Any thought about my previous post? (before yours)

  • #587 / Jul 16, 2010 2:01pm

    nomikos3

    33 posts

    Adding a user profile using DX_auth:

    The last_ip and last_login data only serves to the the administrator user, but not the logged user because they are updated at the beginning of their session.

    So if you want to show this data to the the logged user the best is patch DX_auth::_set_session() (run before that DX_auth::_set_last_ip_and_last_login())

    // line 426 in application/libreries/DX_auth.php:
    
    function _set_session($data)
    {
        // Get role data
        $role_data = $this->_get_role_data($data->role_id);
    
        // Set session data array
        $user = array(
            'DX_user_id'                        => $data->id,
            'DX_username'                        => $data->username,
            'DX_role_id'                        => $data->role_id,
            'DX_role_name'                    => $role_data['role_name'],
            'DX_parent_roles_id'        => $role_data['parent_roles_id'],    // Array of parent role_id
            'DX_parent_roles_name'    => $role_data['parent_roles_name'], // Array of parent role_name
            'DX_permission'                    => $role_data['permission'],
            'DX_parent_permissions'    => $role_data['parent_permissions'],
    
            // add these 2 lines < --------
            'DX_last_ip'                        => $data->last_ip,
            'DX_last_login'                        => $data->last_login,
    
            'DX_logged_in'                    => TRUE
        );
    
        $this->ci->session->set_userdata($user);
    }

    Now you can do something like:

    // auth/profile_view.php:
    
    <fieldset>
    <legend>Your profile</legend>
    <dl>
        <dt>Username:</dt>
        <dd>
            <?php echo $this->session->userdata('DX_username'); ?>
        </dd>
        <i><b>Administrator message</b>: Please tell me about any irregularity:</i>
        
        <dt>Your last session:</dt>
        <dd>
            <?php echo strtotime($this->session->userdata('DX_last_login')) ? date('Y-m-d H:i', strtotime($this->session->userdata('DX_last_login'))) : 'Never' ?>
        </dd>
        <dt>Your last IP:</dt>
        <dd>
            <?php echo $this->session->userdata('DX_last_ip'); ?>
        </dd>
    </dl>
    </fieldset>

    You can store other data like: email, address, phone, etc. using sessions immediately after login:

    // application/controllers/auth.php
    
    function login()
    ...
    if ($val->run() AND $this->dx_auth->login($val->set_value('username'), $val->set_value('password'), $val->set_value('remember')))
    ...
    $newdata['email'] = $email;
    $newdata['phone'] = $phone;
    $newdata['address'] = address;
    
    $this->session->set_userdata($newdata);
    ...

    And added to the user profile:

    // auth/profile_view.php:
    
    ...
    <dt>E-mail:</dt>
    <dd>
        <?php echo $this->session->userdata('email'); ?>
    </dd>
    ...

    Please comment, thanks.
    I.-

  • #588 / Sep 27, 2010 11:16pm

    RS71

    106 posts

    Has anybody fixed the autologin encryption problem? If so, can you help me out?

    Thanks in advance

  • #589 / Sep 29, 2010 8:43am

    i’m facing problem with “remember me” cookie,

    i have client that use ISA server with 100+ workstations,

    when any machine signin with “remember me” all other station will be logged in with same user as they seeing the auto_login cookie!!!  🐛

    anybody faced such thing?! or any idea to overcome this ?

  • #590 / Sep 30, 2010 9:03am

    AskoJr

    5 posts

    Hey, i don’t wanna be “that person” but, I’m having a major problem. I installed the dx_auth library and everything works except that on every form page (login, register, etc) it shows the following:

    A PHP Error was encountered
    
    Severity: Warning
    
    Message: mb_internal_encoding() [function.mb-internal-encoding]: Unknown encoding ""
    
    Filename: libraries/Form_validation.php
    
    Line Number: 57

    What could be the problem?

  • #591 / Sep 30, 2010 9:29am

    AskoJr

    5 posts

    So, i solved the problem by removing the following in Form_validation.php.

    // Set the character encoding in MB.
            if (function_exists('mb_internal_encoding'))
            {
                mb_internal_encoding($this->CI->config->item('charset'));
            }

    I don’t know how important this is, hopefully not much…but just in case someone should reply..

  • #592 / Oct 04, 2010 4:25am

    sugens

    1 posts

    Anybody else having problems with the zip file?  I have tried opening it using three different programs and all three say it is an “invalid archive file”.

  • #593 / Oct 06, 2010 1:34am

    ReyPM

    86 posts

    Hi everyone:
    I tried to use the library but get this error:

    Error Number: 1364
    
    Field 'user_data' doesn't have a default value
    
    INSERT INTO `ci_sessions` (`session_id`, `ip_address`, `user_agent`, `last_activity`) VALUES ('518fe21b0a99f2655566caf8f67467ad', '192.168.0.2', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv', 1286339350)

    while trying to access to any methods, can any help me to solve this or point me in the right direction?

  • #594 / Oct 06, 2010 5:04pm

    ReyPM

    86 posts

    I’m not seeing any captcha on my screen with the simple example.  Any hints what I might be doing wrong?

    Check to make sure you have an exception in your .htaccess file if you have one:

    RewriteEngine on
    RewriteRule ^$ /index.php [L]
    RewriteCond $1 !^(index\.php|img|images|css|js|captcha|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ /index.php/$1 [L]

    Also, make sure you have GD library installed and loaded in PHP

    Hi have GD installed and haven’t any .htaccess file and didn’t see the captcha code, why this?

    Cheers

  • #595 / Oct 06, 2010 5:46pm

    natefons

    30 posts

    wow. great system!

    kudos

  • #596 / Nov 04, 2010 8:57am

    malkabani

    7 posts

    hi
    i am using dx auth in tow website in my server
    but ther is a bug
    when i enter to backend in one site
    the aother site automatic log in
    with out go unto log in form
    can anyone help me

  • #597 / Nov 04, 2010 10:05am

    Stoney

    56 posts

    Use different databases for your sites.

  • #598 / Nov 04, 2010 11:26am

    malkabani

    7 posts

    Use different databases for your sites.

    i use different databases names for my sites
    but same table names

  • #599 / Nov 04, 2010 12:13pm

    33cent

    26 posts

    also try different cookie names 😉

  • #600 / Nov 05, 2010 4:38am

    Stoney

    56 posts

    Strange, I have more than 5 sites with dx_auth with the same config, and all working fine.
    Every cookie has his domain and path defined, so they don’t interfere with each other.

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

ExpressionEngine News!

#eecms, #events, #releases