• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
flexi auth - A user authentication library for CodeIgniter

#51
[eluser]haseydesign[/eluser]
Hey Caprisun,

Your problem is almost certainly related to a problem with your original configuration when setting up the auth library.

From the error message you have stated, it suggests to me its something to do with the user group table.

The purpose of user groups is for them to be used to enforce security within a site, restricting access to specific content based on the user group that a user belongs to.

To try fixing the problem, first of all I would check that your have at least one user group defined within the table. Typically even the most basic of sites would have 2 rows, 'public user' and 'admin user'.

If your table does contain records, then check the tables settings are defined correctly via the flexi auth config file.

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

If you have no luck with finding out if the user group tables are the problem, then I would suggest you go through the installation guide step by step and install the demo files and sql dump.

The demo example within the Github repo is a replica of everything you can access via the live demo at http://haseydesign.com/flexi-auth/

Let us know how you get on.

#52
[eluser]caprisun[/eluser]
Thanks the installation didn't add these groups, the structure was there though.
Problem solved, all working like a charm right now.

Hope to setup my project without any further problems, if so ill let you know.

#53
[eluser]C4iO [PyroDEV][/eluser]
@haseydesign


Hi there! This is my first time using your library and because of that, I was going to do exactly what you recommend, play with the demo.

So I've downloaded and installed everything yesterday, but when I try to login, CI gives me this error:

Quote:A Database Error Occurred

Error Number: 1364

Field 'usess_series' doesn't have a default value

INSERT INTO `user_login_sessions` (`usess_uacc_fk`, `usess_token`, `usess_login_date`) VALUES ('1', '59f3540717c4ff6d6f5273ea17e584d45bff395a', '2012-10-09 11:55:04')

Filename: C:\zend\Apache2\htdocs\flexi_auth\system\database\DB_driver.php

Line Number: 330

I'm using the latest version of Zend Server CE on a Windows machine (as you can tell by the path on "Filename" line).

Since I'm still trying to understand a bit more the library, I'm not sure if I can just set a default value directly at the db structure or if I can do that somewhere within the library files.

Can you help me with that?



Thx in advance

#54
[eluser]haseydesign[/eluser]
In reply to an email I received from 'Wills', this may also help others with the same problem.

Quote:I use the routes function in codeigniter to make prettier URLS but when I set the logout one to:
$route['logout'] = 'auth/logout';

All it does is goes to the user dashboard, but accessing the URL auth/logout, it logs out nicely. Any ideas?

This is simply a conflict with the way the demo example has been setup, and is not a problem with the library.

In the __construct() of the current 'auth' controller, there is an IF condition that performs a redirect if true.
Code:
if ($this->flexi_auth->is_logged_in_via_password() && uri_string() != 'auth/logout')

Because of the new url routing the uri_string() function would now return 'logout', rather than 'auth/logout', and therefore causing a the __construct() to redirect before the logout method got to be called.

Changing the code to the following would allow for both url paths.
Code:
if ($this->flexi_auth->is_logged_in_via_password() && ! in_array(uri_string(), array('auth/logout', 'logout')))

#55
[eluser]haseydesign[/eluser]
@PyroDev

This error seems to be related to the CodeIgniter database config (application/config/database.php):
Code:
$db['default']['stricton'] = TRUE;

If this is defined as TRUE, then I also get the same errors as yourself.

If you were to update the database table 'user_login_sessions' with the following sql statement it would fix this particular error message.
Code:
ALTER TABLE `user_login_sessions`
MODIFY COLUMN `usess_series`  varchar(40) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '' AFTER `usess_uacc_fk`;

However, you will then receive other errors for other table columns that also do not have a default value defined.

So your options are, either update your CI database config as follows:
Code:
$db['default']['stricton'] = FALSE;

Or alternatively, you will need to go through all of the libraries database tables and define default values for each column.

Hope that helps.

#56
[eluser]C4iO [PyroDEV][/eluser]
@haseydesign

Thanks for your reply.

I've fixed it setting the column to allow NULL and it's default value to NULL also. It seems to be fixed, since I have not noticed any errors after.

One thing it's weird though, I've checked my db config and striction it's set to false already.

Later on, I caught myself thinking setting "usess_series" to NULL as default value, makes sense as Barry Jaspan states in the first 2 items of his "Improved Persistent Login Cookie Best Practice" solution that:

Quote:1. When the user successfully logs in with Remember Me checked, a login cookie is issued in addition to the standard session management cookie.
2. The login cookie contains the user's username, a series identifier, and a token. The series and token are unguessable random numbers from a suitably large space. All three are stored together in a database table.

If the user doesn't check Remember Me, that cookie wouldn't need to be set, right? If so, the "usess_series" column wouldn't have to set a default value other than NULL or another value that represents emptiness.

Well... that makes sense to me. If you have another point of view of this particular subject, I'll be more than glad to hear.

BTW... Great auth lib!




Cheers

#57
[eluser]C4iO [PyroDEV][/eluser]
@haseydesign

Hey there, sorry if I'm spamming, but I'm struggling to get Flexi Auth working on a dedicated server I have.

I've uploaded everything, imported sql dumps and changed configs, but oddly I can't login.

I thought some change I've made caused this, so I've uploaded a fresh copy of CI and Flexi Auth, did everything again (installation instructions), but no success.

Can you help me out?

This project is at this url: http://appnavigators.com.br/ebx/novocrm

Please tell me if there's any other information that might be helpful.

UPDATE 11 Oct 2012

I've found the reason for this issue on my server is PHP, which is running 5.2.17. After a very quick research on that, I've also found a PHP version lower than 5.3 doesn't have CRYPT_BLOWFISH implementation and relies on OS to provide support.

#58
[eluser]haseydesign[/eluser]
@PyroDev

After checking the flexi auth installation on your link and the subsequent update message you left, i'm assuming you got things working properly; is that right?

Once you worked out that the php version was causing the issue, how did you go about solving it?

#59
[eluser]C4iO [PyroDEV][/eluser]
@haseydesign

I've asked for the upgrade to PHP 5.3 with mbstring enabled to my hosting company, but until they do that, I've made a helper to fullfil the lack of two functions Flexi uses. I'm pretty sure it's not the best code ever, but at least it's a start to make backward compatibility where mbstring isn't enabled.

mbstring_helper.php source code:
Code:
<?php

if (!function_exists('mb_strlen')) {
function mb_strlen($string) {
  return preg_match_all( '(.)su', $string, $matches );
}
}


if (!function_exists('mb_substr')){
function mb_substr($string, $start = 0, $length = NULL) {
  $pattern = '^';
  if ($start > 0)
   $pattern .= '(?:.{'.$start.'})';
  else
   $pattern .= '(?:.*)';

  if (!is_null($length) && $length > 0)
   $pattern .= '(.{'.$length.'})';
  else
   $pattern .= '(.*)';

  preg_match('/'.$pattern.'/', $string, $matches);

  return $matches[1];
}
}

Finally, what do you think about setting usess_series to NULL as default value, as I've mentioned earlier? It is working so far.



Thanks!!!!

#60
[eluser]Unknown[/eluser]
Hi,

I'm using Flexi auth and everything goes well until I use AJAX. With the user logged in, an AJAX request to a controller is done. This controller then uses a model to store some info to the database. When the user then goes to another page, he has been logged out.

At first I was trying to obtain the user id in the controller, but the is_logged_in function returned false. I thought the problem was using the Flexi auth library in the AJAX request, so I took out all Flexi auth code from the controller, but the user session continues to be closed.

Any idea of what can be happening?

Cheers.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.