Welcome Guest, Not a member yet? Register   Sign In
DX Auth 1.0.6 (Authentication library)

[eluser]Unknown[/eluser]
Hi there - I would like to try and use this library for my project, but not sure if it would be possible.

Essentially, I need the ability for users to have a role tied to other users in the system.

The example would be:
User 1
-> Is a BRONZE role for User5
-> Is a SILVER role for User6

User 2
-> Is a GOLD role for User5
-> Is a SILVER role for User6

The role permissions should be able to be used as is, but not sure how I would accomplish the above.

Maybe a UserToRole table
- ID
- UserID -> My ID
- RoleID - > My role
- OtherUSERID -> The user for which I belong to that role


Thoughts?

[eluser]nomikos3[/eluser]
HI,
Yesterday I opened a discussion about banned users. Now I know that here is the correct place to talk about DX.
Please check http://ellislab.com/forums/viewthread/160497/
I would like to path the code...
o/\o

[eluser]trickymatt[/eluser]
Hello,

Great library!

I am having an issue with the is_role() function.

I have the following 'if' statement:

Code:
if ($this->dx_auth->is_role('User'))
        {
            echo 'sales controller';
        }
        else
        {
            echo 'sales controller, but you are not sales';
        }

Everything is ok when the page is accessed by a 'user'. However, if the page is accessed by someone who is not a 'user', and the above 'else' statement is invoked, I get the following error:

A PHP Error was encountered

Severity: Warning

Message: array_push() [function.array-push]: First argument should be an array

Filename: libraries/DX_Auth.php

Line Number: 717

Any help kindly appreciated. Thanks

[eluser]nomikos3[/eluser]
file: application/libraries/DX_Auth.php
Code:
...
function is_role($roles = array(), $use_role_name = TRUE, $check_parent = TRUE)
{
    // Default return value
    $result = FALSE;

    // Build checking array
    $check_array = array();

    if ($check_parent)
    {
        // Add parent roles into check array
        if ($use_role_name)
        {
            $check_array = $this->ci->session->userdata('DX_parent_roles_name');
        }
        else
        {
            $check_array = $this->ci->session->userdata('DX_parent_roles_id');
        }
    }

    // Add current role into check array
    if ($use_role_name)
    {
        /* line 717 */
        array_push($check_array, $this->ci->session->userdata('DX_role_name'));
    }
    else
    {
        array_push($check_array, $this->ci->session->userdata('DX_role_id'));
    }
...

Hi trickymatt.
Obviously is a problem due sessions ($check_array is overwrited by $this->ci->session). Check that the user is logged in before reach this statement..
Something like this at the top of your controller:

Code:
if ( ! $this->dx_auth->is_logged_in())
{
    redirect('auth/login'); // or similar...
}

[eluser]trickymatt[/eluser]
@NomikOS - thanks for your help, that fixed it.

[eluser]nomikos3[/eluser]
You are welcome. Any thought about my previous post? (before yours)

[eluser]nomikos3[/eluser]
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())

Code:
// 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:

Code:
// auth/profile_view.php:

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

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

Code:
// 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:

Code:
// auth/profile_view.php:

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

Please comment, thanks.
I.-

[eluser]RS71[/eluser]
Has anybody fixed the autologin encryption problem? If so, can you help me out?

Thanks in advance

[eluser]khalil Majdalawi[/eluser]
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!!! :bug:

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

[eluser]AskoJr[/eluser]
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:

Code:
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?




Theme © iAndrew 2016 - Forum software by © MyBB