Community Auth - a database error when logging in |
Hi,
I have installed Community Auth (current master) with CodeIgniter 3.1.4. The configurations are: Code: $config['sess_driver'] = 'files'; Added an encryption key using Key_creator.php Edited Examples.php Code: public function create_user() An account is created using /examples/create_user Checked the DB user table and the user exists However when I try to login, I get a database error: A Database Error Occurred Error Number: 1048 Column 'id' cannot be null INSERT INTO `auth_sessions` (`id`, `user_id`, `login_time`, `ip_address`, `user_agent`) VALUES (NULL, '309003055', '2017-04-10 14:11:54', '84.92.55.111', 'Chrome 57.0.2987.133 on Mac OS X') Filename: third_party/community_auth/models/Auth_model.php Line Number: 90 $session_id seems to be NULL.. Do you have any idea why it keeps getting this error? Thanks.
Can you verify that the session actually exists in the location you are attempting to store it?
sys_get_temp_dir() is your location. The id of auth_sessions is the CI session ID, and it's only NULL because that's what's being passed to it from the CI session library. My advice is to make sure plain CI sessions are working with your application, and you'll probably see that Community Auth starts working.
04-11-2017, 12:57 PM
(This post was last modified: 04-11-2017, 11:00 PM by icteroo. Edit Reason: typo )
Thanks for your reply.
I have tested with the following: Code: public function test() and I got the result: in the browser http://mydomain.com/welcome/test array(4) { ["__ci_last_regenerate"]=> int(1491940229) ["auth_identifiers"]=> string(81) "a:2:{s:7:"user_id";s:9:"309003055";s:10:"login_time";s:19:"2017-04-11 19:55:38";}" ["username"]=> string(8) "testuser" ["logged"]=> bool(true) } on the server Code: /tmp $ sudo cat ci_sessionvg3kcrpgn7i2h0jggdbvm1j4ed64u7li I think CI session is working fine...
When I use your session config, all is working fine. This is on Ubuntu 16.04 with PHP7.
What is the value of your encryption key? Mine in example is like this: PHP Code: $config['encryption_key'] = hex2bin('5d3a06b1a1efeb861ad761fb8839794f'); (04-11-2017, 03:18 PM)skunkbad Wrote: When I use your session config, all is working fine. This is on Ubuntu 16.04 with PHP7. Mine is Code: $config['encryption_key'] = hex2bin('31a953d513fa2c32ae58b5520b495745');
If you can zip up your site, and include a current dump of your database, and make it accessible for me to download, I'd like to figure out what's going on. I'd be glad to do it.
This is what I had to do with your files to get things working:
1) Set the value of base_url in config/config to an actual domain. 2) Changed "admin" on line 41 of controllers/Examples.php to "superuser". You changed the names of the roles in config/authentication, but they are not appropriate for the examples. If you want to use the examples without altering them, then you need to change your roles back to the way they come from the Community Auth repo. That's all it took for me to get it working. Also, if you want to confirm things are just the way they are on my system (Ubuntu 16.04), then you can use the dev installer located at /community_auth/sh/.development_install.sh. I put that in /var/www, and then run it. I have a complete working install in about 5 seconds. I am of course using virtual hosts... but its worth a try to see if it works for you.
Re-installed everything from scratch and it works fine.
Thanks a lot for your help and great code!! |
Welcome Guest, Not a member yet? Register Sign In |