fuel / auth

Fuel PHP Framework - Fuel v1.x Authentication package
http://fuelphp.com/docs/packages/auth/intro.html
76 stars 57 forks source link

Bug with simpleauth.table_columns? #114

Closed Daijobou closed 8 years ago

Daijobou commented 8 years ago

config/simpleauth.php I set 'table_columns' => array('id','username','email','last_login','login_hash','group','profile_fields'),

I found this line https://github.com/fuel/auth/blob/1.8/master/classes/auth/login/simpleauth.php#L87 make a strange output. The select is not "SELECT id,username,email,..." its "SELECT *,id,username,email,..." That star here is wrong. In my controller I write:

Config::load('simpleauth', true);
var_dump(Config::get('simpleauth.table_columns', array('abc')));

result is:

array(8) {
  [0]=>
  string(1) "*"
  [1]=>
  string(2) "id"
  [2]=>
  string(8) "username"
  [3]=>
  string(5) "email"
  [4]=>
  string(10) "last_login"
  [5]=>
  string(10) "login_hash"
  [6]=>
  string(5) "group"
  [7]=>
  string(14) "profile_fields"
}

The star is merged from /packages/auth/config/simpleauth.php

WanWizard commented 8 years ago

I can't see your comment in the Github GUI, but I got the email.

Yes, this fixes it. Configurations are merged using Arr::merge(), and that can't merge indexed array's due to the lack of keys, so the array's are added together instead. Which is why you end up with a config array that contains both the default values from auth/config/simpleauth.php and your configuration from app/config/simpleauth.php. By changing it to null, this is avoided.

The null value would also make sure that if your custom config doesn't contain the table_columns entry, the get() in the code would return it's default, which is array('*').

Daijobou commented 8 years ago

Thank you very much for your good explaination. I have deleted my post. :)