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 - 03-09-2013

[eluser]ReyPM[/eluser]
I'm asking if is possible to log when a user login and user logout (timestamp both) in order to get more control over login users. Any suggestion?


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

[eluser]NotSmilie[/eluser]
[quote author="ReyPM" date="1362890541"]I'm asking if is possible to log when a user login and user logout (timestamp both) in order to get more control over login users. Any suggestion?[/quote]
You could create a new table with a FK to user, IP, action (enum: 'Logged in', 'Logged out'), timestamp (datetime).

Then you could use this to populate the table: Insert custom user data


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

[eluser]haseydesign[/eluser]
@NotSmilie

The general flow of your function looks correct, with a possible exception to the table names (Which you mention you're unsure of).

The array keys and values that your are passing to the update_user() function need to reflect the exact name of the table column you are updating and the value you are updating it to.

Therefore, assuming you haven't changed any column names from the default, your code would look a little like the following: (Note: I tidied the code duplication you were using)
Code:
$user_data = array(
  'uacc_email' => $_POST['uacc_email'],
  'uacc_username' => $_POST['uacc_username'],
  'uacc_group_fk' => $_POST['uacc_group_fk'],
  'uacc_credits' => $_POST['uacc_credits'] // This is your own custom column, so make sure the name matches.
);

if ($_POST['uacc_password'] != '')
{
  $user_data['uacc_password'] = $_POST['uacc_password'];
}
An important note is to ensure that the form inputs your are retrieving from $_POST are named as you have put them above (Since those names are also the same as the database column names). Also ensure the $user_id is correct.

If you're unsure how to check the content of these variables, use the following code:
Code:
echo '<pre>';
print_r($_POST);
exit;

If you're still stuck, check out the demo that is included with the library and look at the update_account() method within the demo_auth_model.php file, as that has a similar example.


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

[eluser]haseydesign[/eluser]
@ReyPM

As user NotSmilie commented above, whenever you call the login() or logout() functions, check whether they were successful or not and then insert the action/result into a custom table that you have created.

You can either use a custom table that is not linked to the library (Via config file settings), or as NotSmilie has stated, you could use the libraries insert_custom_user_data() function.

Thanks NotSmilie for helping out with your answer!


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

[eluser]NotSmilie[/eluser]
@haseydesign
Thanks, this worked for my non-custom fields.
I printed out the custom field from the form, and it was submitted correctly.

For some reason it doesn't update the field in the database. As you probably noticed I just added a field to the default user table, and made it a double.
Should I use another function (method) to update this individual field?


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

[eluser]haseydesign[/eluser]
@NotSmilie

You probably haven't defined your custom column correctly via the flexi auth config file, so it doesn't know what to do with the column.

This will hopefully help you out:
Code:
$config['database']['user_acc']['custom_columns'] = array(
  'uacc_credits'
);



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

[eluser]ReyPM[/eluser]
I've been working on a site and using FlexiAuth in my development server (local virtual Machine with CentOS) I get no errors, now I move to my hosting and get this:

Quote:A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/flexi_auth_model.php

Line Number: 1770
A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/flexi_auth_model.php

Line Number: 1773
A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/flexi_auth_model.php

Line Number: 1773
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/reynierp/public_html/newplat/system/core/Exceptions.php:185)

Filename: libraries/Session.php

Line Number: 675

Why?


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

[eluser]haseydesign[/eluser]
@ReyPM

If you are using the exact same CI setup on your development enironment (Where it works) and your production server (Where it doesn't work), then it is almost certainly something to do with the setup of the production servers PHP or Apache.

If you can, try and run phpinfo() on your dev server and production server and compare the differences between the servers.
At the least, try and run both on the same version of php.

I'm not sure on the minimum PHP version, but I know it works from 5.3+, but should work from 5.2+.


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

[eluser]NotSmilie[/eluser]
[quote author="haseydesign" date="1363083362"]@NotSmilie

You probably haven't defined your custom column correctly via the flexi auth config file, so it doesn't know what to do with the column.

This will hopefully help you out:
Code:
$config['database']['user_acc']['custom_columns'] = array(
  'uacc_credits'
);
[/quote]

Great, I got a bit further, something is wrong when it\s generating the queries though:
http://i.imgur.com/Nh3uQDL.png

(code below)

So, it knows that it needs to insert 5 from the form, however no column is specified for some reason, any idea?

Code:
Credits: 5
A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: models/flexi_auth_model.php

Line Number: 310

A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user_accounts`.`uacc_id` = '2'' at line 1

UPDATE `user_accounts` SET `user_accounts`.`uacc_group_fk` = '1', `user_accounts`.`uacc_email` = 'test2@test.com', `user_accounts`.`uacc_username` = 'Test2', ` = '5' WHERE `user_accounts`.`uacc_id` = '2'

Filename: C:\xampp\htdocs\market\admincp\system\database\DB_driver.php

Line Number: 330




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

[eluser]ReyPM[/eluser]
Well the only change between production server and development server is in index.php where I set production instead of development (leave development for a while to see errors). In my production server I'm runinng PHP 5.3.18 and in development is 5.4.12 other than that there are not changes