Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Auth::get_user_id() should not return empty array when guest user config is disabled?
  • Ok, it is not a problem but it does API inconsistent, in my opinion, see:
    In Auth_Login_Driver (auth/classes/auth/login):

    /**
    * Get User Identifier of the current logged in user
    * in the form: array(driver_id, user_id)
    *
    * @return  array
    */
    abstract public function get_user_id();

    And in simpleauth.php:
    /**
    * Get the user's ID
    *
    * @return  Array  containing this driver's ID & the user's ID
    */
    public function get_user_id()
    {
    if (empty($this->user))
    {
    return false;
    }

    return array($this->id, (int) $this->user['id']);
    }

    Is not supposed get_user_id should return an empty array even though guest user config is disabled, In compliance with API?
    Because of method signature informs that returns is array, so Auth::get_user_id should always return array

    Currently if guest_login => false in config/simpleauth.php 
    Auth::get_user_id returns false.


    again, this is not exactly a problem
  • If there is nobody logged in, and there is no guest user account, what would you suggest it returns?

    array(false,false) is a bit weird too, it's better to modify the method signature. If only because changing this will break every application using Auth.
  • "If there is nobody logged in, and there is no guest user account, what would you suggest it returns?"
    An empty array.

    array(false,false) is a bit weird too, it's better to modify the method signature. If only because changing this will break every application using Auth.
    Yes, you're right! :)


    Thanks, Harro!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion