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

[eluser]dexcell[/eluser]
[quote author="trice22" date="1228161583"]Thanks for your contribution—I'll give it a try.

Could anyone put up a comparison matrix for all the auth system we have now? —I've lost track long time ago. :cheese:

—trice[/quote]

Thanks, before when i was searching for a auth system, CL Auth was the best in my opinion in feature, but unfortunately the author become very busy and don't have time to fix the bug and maintain the library to make it compatible with CI latest library.

When i dig the code, i think CL Auth has already a very good code base, that's why i choose to take CL Auth to the next level and the result is DX Auth.
#12

[eluser]RHAngel[/eluser]
I think you need to rewrite
Code:
$this->ci->lang->load('dx_auth', 'english');

to

Code:
$this->ci->lang->load('dx_auth');

Or move language to config file, only 'english' is a bad choice. If I use other language I need to rewrite it by myself every time you update the library to the next version.
#13

[eluser]dexcell[/eluser]
[quote author="RHAngel" date="1228163025"]I think you need to rewrite
Code:
$this->ci->lang->load('dx_auth', 'english');

to

Code:
$this->ci->lang->load('dx_auth');

Or move language to config file, only 'english' is a bad choice. If I use other language I need to rewrite it by myself every time you update the library to the next version.[/quote]

Thank you, i totally forgot about that, will remove that english string so it will use language specified by CI config.
#14

[eluser]Rey Philip Regis[/eluser]
Sounds interesting..I'll try that library maybe next week or the week after next hehe, I will create a web portal after my current project, so I might use that DX Auth library of yours..Hope that all problems that RHAngel posted are fixed, when I downloaded the library next week.

Good day.
#15

[eluser]dexcell[/eluser]
@RHAngel
Just little question to you, before i add it to the source code.

Because i always put my all my tables in the same database, so i don't know the answer.

About this code (i change the variable a bit)
Code:
$this->ci->load->database($this->ci->config->item('DX_database_group_name'));


Does using code like this wouldn't having some 'collision' with other code that using default active group/default database ?

I mean, Will CI take care of the rest in the background even if we load 2 database at once and return the correct one when i call it in the model?

I have read CI user guide about using multiple database, and if i should follow that, then looks like i have to change all the model just for one line Tongue (even tough looks like just renaming and testing).

But if that's the case, i will consider adding it in the future, but not in these current day because i have my project to do.

And of course if you willing to help me by writing and testing it, i'm gonna add it to DX Auth source code Smile
#16

[eluser]RHAngel[/eluser]
Oh, it is my fault. To use separate database we need to return connection in separate object. Like in example:
Code:
$DB1 = $this->load->database('group_one', TRUE);

So, I'm sorry. Smile

By the way. Library is not compatible with PostgreSQL when you use quotes in table names or fields, because of plain SQL in models. To use this library with PostgreSQL you guys need to rewrite all plain SQL in models like:

Code:
$sql = "SELECT $u_table.*,
            $r_table.name AS role_name
            FROM $u_table
            JOIN $r_table ON $r_table.role_id = $u_table.role_id
            ORDER BY $u_table.user_id ASC";

to

Code:
$sql = "SELECT \"$u_table\".*,
            \"$r_table\".\"name\" AS \"role_name\"
            FROM \"$u_table\"
            JOIN \"$r_table\" ON \"$r_table\".\"role_id\" = \"$u_table\".\"role_id\"
            ORDER BY \"$u_table\".\"user_id\" ASC";


dexcell maybe you can rewrite all queries to active record? 8) Or may be I can help you.
#17

[eluser]RHAngel[/eluser]
Also.. Why "is_admin" function query database to check user is admin or not. Maybe we can store role name in session userdata or use role id and check without additional query?

Code:
function is_admin()
    {
        // Load Models
        $this->ci->load->model('dx_auth/users', 'users');
        
        return $this->ci->users->check_admin($this->ci->session->userdata('user_id'))->num_rows() > 0;
    }

to something like

Code:
function is_admin()
    {        
        return $this->ci->session->userdata('role_id')==1?TRUE:FALSE;
    }

I don't know how are you, but I'm really don't like tons of queries to database for such simple functions.
#18

[eluser]dexcell[/eluser]
[quote author="RHAngel" date="1228171275"]Oh, it is my fault. To use separate database we need to return connection in separate object. Like in example:
Code:
$DB1 = $this->load->database('group_one', TRUE);

So, I'm sorry. Smile

By the way. Library is not compatible with PostgreSQL when you use quotes in table names or fields, because of plain SQL in models. To use this library with PostgreSQL you guys need to rewrite all plain SQL in models like:

Code:
$sql = "SELECT $u_table.*,
            $r_table.name AS role_name
            FROM $u_table
            JOIN $r_table ON $r_table.role_id = $u_table.role_id
            ORDER BY $u_table.user_id ASC";

to

Code:
$sql = "SELECT \"$u_table\".*,
            \"$r_table\".\"name\" AS \"role_name\"
            FROM \"$u_table\"
            JOIN \"$r_table\" ON \"$r_table\".\"role_id\" = \"$u_table\".\"role_id\"
            ORDER BY \"$u_table\".\"user_id\" ASC";


dexcell maybe you can rewrite all queries to active record? 8) Or may be I can help you.[/quote]

Thank you, if you don't mind please help me Smile two brains is better than one, of course.
But i have to sleep now because it's already late midnight in here Big Grin
Of course, i will give credit to you in source code and user guide Smile

Yes, i was planning to write it whole model in AR, but some bug and some limitation of CI AR like using UPPER(table_name) is not possible (maybe my mistake?).

Btw, just curious is there a way to check if database using PostgreSQL or mySQL in CI? maybe if some code cannot be converted into AR we can use this function to check.
#19

[eluser]dexcell[/eluser]
[quote author="RHAngel" date="1228172055"]Also.. Why "is_admin" function query database to check user is admin or not. Maybe we can store role name in session userdata or use role id and check without additional query?

Code:
function is_admin()
    {
        // Load Models
        $this->ci->load->model('dx_auth/users', 'users');
        
        return $this->ci->users->check_admin($this->ci->session->userdata('user_id'))->num_rows() > 0;
    }

to something like

Code:
function is_admin()
    {        
        return $this->ci->session->userdata('role_id')==1?TRUE:FALSE;
    }

I don't know how are you, but I'm really don't like tons of queries to database for such simple functions.[/quote]

That's because in roles database,the admin role_id wasn't fixed, so you cannot check using that way.

Maybe i should fix admin role_id into 2, so we can check that way.

Thanks for your input i'm gonna change the code and user guide to fix the admin role_id and upload it tomorrow.
#20

[eluser]RHAngel[/eluser]
Code:
$this->db->platform()

I don't recommend to check platform and write multiple solutions for a different databases. I will try to rewrite models to AR, and report about my progress.




Theme © iAndrew 2016 - Forum software by © MyBB