CodeIgniter Forums
flexi auth - A user authentication library for CodeIgniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: flexi auth - A user authentication library for CodeIgniter (/thread-54581.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34


flexi auth - A user authentication library for CodeIgniter - El Forum - 05-28-2013

[eluser]haseydesign[/eluser]
@devha

The problem you highlight was a known issue in earlier versions of the library, but this should since have fixed from happening when all references to table columns within the library models were updated to prepend the table name to each column name (e.g. uacc_id became user_accounts.uacc_id).

Are you using a recent copy of the library?

-------------------------------------------------------

@aresproject

If you are asking how you set a menu to show/hide depending on a users privilege, then you're right with using the is_privileged() function.

As for dynamically showing the menu, this sounds more like a CSS and Javascript task.
Typically I would create a Javascript event attached to a html class, that when triggered would show/hide the element with the corresponding class.

You then only include the html class within the menu for users that are identified as having the privilege defined via the is_privileged() function.

Is that what you were asking?


flexi auth - A user authentication library for CodeIgniter - El Forum - 05-28-2013

[eluser]devha[/eluser]
[quote author="haseydesign" date="1369748920"]@devha

The problem you highlight was a known issue in earlier versions of the library, but this should since have fixed from happening when all references to table columns within the library models were updated to prepend the table name to each column name (e.g. uacc_id became user_accounts.uacc_id).

Are you using a recent copy of the library?
[/quote]

I downloaded the zip from github in the beginning this week so I should have the lates version.

Tried this once again, I changed the column naming in user_accounts and user_groups tables and updated the configuration. Right now I have only one user in my users table (id 1) but after the name change, the library returns user id 2, which is the same as the user group id.


flexi auth - A user authentication library for CodeIgniter - El Forum - 05-29-2013

[eluser]Lee.[/eluser]
Hello,

The ZIP isn't available on Git right now, there is a 404 error.

Any other location I can download from?

Regards,
Lee


flexi auth - A user authentication library for CodeIgniter - El Forum - 05-29-2013

[eluser]haseydesign[/eluser]
@devha

Is the error coming from a function where you are stating your own SQL SELECT statement, or is it from using flexi auth library function with default parameters?

Which function is it that is causing the problem?

------------------------------------------------------------------------------------------

@Lee

Github must have been temporarily having issues, all seems good now.


flexi auth - A user authentication library for CodeIgniter - El Forum - 05-29-2013

[eluser]devha[/eluser]
[quote author="haseydesign" date="1369824914"]@devha

Is the error coming from a function where you are stating your own SQL SELECT statement, or is it from using flexi auth library function with default parameters?

Which function is it that is causing the problem?
[/quote]
Im using standard flexi auth function get_user_by_id(), and my flexi auth setup is pretty much standard stuff, only some configuration changes (and table columns renamed).

print_r($this->flexi_auth->get_user_by_id()->row(), true)

Outputs:

DEBUG - 2013-05-29 20:07:48 --> stdClass Object
(
[id] => 2
[group_fk] => 2
[email] => [email protected]
[username] => demo
[password] => *removed*
[ip_address] => ::1
[salt] => tHBJJFpYcw
[activation_token] => a24d49bc6a256580a84fef6b14f90891b163b544
[forgotten_password_token] =>
[forgotten_password_expire] => 0000-00-00 00:00:00
[update_email_token] =>
[update_email] =>
[active] => 1
[suspend] => 0
[fail_login_attempts] => 0
[fail_login_ip_address] =>
[date_fail_login_ban] => 0000-00-00 00:00:00
[date_last_login] => 2013-05-29 20:06:00
[date_added] => 2013-05-23 22:03:24
[name] => Public
[desc] => Public User
[admin] => 0
)

Id is incorrect, it should be 1, now it is user group id.

I think the root of the issue is that the flexi auth gets data from user account and user group tables, both tables have column named id. Now when this data is merged to one object, user account id gets overwritten by user group id as they both have the same identifier.


flexi auth - A user authentication library for CodeIgniter - El Forum - 05-30-2013

[eluser]Lee.[/eluser]
Hello,

I have a pretty simple question.

I have designed a login page and "borrowed" the login function from the demo, which works.

However, I have included the login box in a header which isn't on the login page - and I set the form action to action="user/login" which is where my login page resides. This works on the login page itself as it uses the current_url() function. But on my header, it just redirects to that page when login is submitted and nothing works.

Any examples of using inline login like I want to?

Regards,
Lee


flexi auth - A user authentication library for CodeIgniter - El Forum - 05-30-2013

[eluser]Lee.[/eluser]
Also, I see in your flexi lite library you have a way to grab the user_id and user_identity (which is the email) - but is there a way to easily grab the username already built in?


flexi auth - A user authentication library for CodeIgniter - El Forum - 06-03-2013

[eluser]haseydesign[/eluser]
@devha

Your assumption is correct, when CodeIgniters Active Record returns the SQL query as an object/array, any identically named columns will be overwritten by the value within the last column of the same name.
This is CI's default behaviour, and to be honest, exactly what I would expect it to do - it can't rename the columns as it doesn't know what to name them.

One potential solution would be to use flexi auth functions that allow you to define the SQL SELECT columns.
You could then define identically named columns as follows:
Code:
$user_id = 123;
$sql_select = 'user_accounts.id AS "user_accounts_id", user_groups.id as "user_groups_id", ...''
$this->flexi_auth->get_user_by_id($user_id, $sql_select);

But as you can probably gather from that code - why bother...
Just name the columns uniquely in the first place and this problem doesn't exist.
It's a practice I always try to implement as it just prevents such small but crippling problems from arising, plus it removes ambiguity, as when you look at the column name - you should easily be able to work out what table its from.


flexi auth - A user authentication library for CodeIgniter - El Forum - 06-03-2013

[eluser]haseydesign[/eluser]
@Lee

Regarding the login form within the header of a page.
What you describe is of course entirely possible, it shouldn't really be any trickier that your primary login form.

What I would start with is ensuring that the post data from the header form is actually being received properly when submitted to your 'user/login' controller/method. Simply put the following code at the start of your 'user/login' controller and method:
Code:
echo '<pre>';
print_r($_POST);
exit;

If that is receiving the data properly, just ensure that you direct the flow of data to the flexi auth login function - just like you suggest is happening via the primary login form.

--

Regarding whether there is a specific function to return the username - no there isn't.
If your flexi auth primary identity column was setup as the username, then the get_user_identity() function would do this, but you state that the users email is the primary identity.

Therefore, probably the easiest way to return the username is via the get_user_by_id() or get_user_by_identity() functions.
Code:
$sql_select = 'uacc_username';
$user_data = $this->flexi_auth->get_user_by_id(false, $sql_select)->row_array();
echo $user_data['uacc_username'];

HTH


flexi auth - A user authentication library for CodeIgniter - El Forum - 06-03-2013

[eluser]devha[/eluser]
@haseydesign

Thanks for your reply! Renaming table columns is not mandatory for me so I think im ok with your naming style with flexi auth tables.


Btw. is there any way to get message "Your login session has expired" after user has been idle too long and the login session has expired.

I have this kind of check in my site:

if ($this->flexi_auth->is_logged_in())
{
...
}
else
{
echo $this->flexi_auth->get_messages()
}

But get_messages() does not return anything when the session expires. I have tried to set flexi auth login_session_expire to 30 sec, CI session expire is 8h.