Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Getting User Groups??
  • Ok can someone please help me with this Auth class.. it seems to painful to try and go through this, but I want to try and keep to it...
    So in the login, I have Auth::instance(); to start a new instance of the Auth class. Well they login. Go to the homepage. Everything is dandy.

    I go to the news page. It loads fine UNTIL I even type ANYTHING dealing with the Auth class whether it's Auth::get_groups() or Auth::instance();...
    It overwrites the sessions or something whenever I do anything dealing with the Auth class in my news controller.
    I saw that you might have to grab the SAME instance of the Auth class that you did in the login controller.. but I'm not sure how to do so.
    I'm just completely irritated. All I want to do it get the group_id so I can allow admins to edit/delete news posts...

    Can someone PLEASE help me?
  • If it helps any, here is what I have in the controller:

    public function action_index()
    {
                $view = View::forge('news/index');
                $news_array = Model_News::get_news(date('m'));
                if (parent::$userid == true) {
                    if(Auth::member(100, parent::$userid)) {
                        //user is admin
                        $admin = true;
                    } else {
                        //user is not admin
                        $admin = false;
                    }
                } else {
                    //user is not logged in nor admin
                    $admin = false;
                }
                
                $view->set('news_array', $news_array, false);
                $view->set('admin', $admin, false);
                $this->template->content = $view;
            }

    Everything works fine UNTIL I do the Auth::member() function. If I delete that and just put whatever I want in the $admin variable, it keeps me logged in.
  • The default instance is accessed via Auth::instance(). All static method calls also use the default instance, so as long as you don't create a second instance manually, there won't be one that could be used.

    The issue is that the prototype of member() is: member($group, $driver = null, $user = null)

    which means you're passing the userid (why parent:: btw? that's a really odd way to access a property) as the driver, you should include either the driver name, or null.

    p.s. to check membership of the current user, you only have to pass the group number.
  • Ok... anytime I use Auth::ANY FUNCTION HERE.. it erases my set sessions and logs me out. Doesn't matter which function I use. ANY of them logs me out..
    So I'm not even sure on how to do anything.
    And I have a protected static variable in the Base Controller called $userid getting the user on every page load so I dont have to do it in every single controller because it was logging me out when I did that as well.
  • Are you sure it's this, and not the fact that you have a cookie issue?

    Have you checked if your session cookies are ok? If your time configuration is not ok (server timezone === php.ini date.timezone === fuel config timezone), GMT time calculations fail, and you will lose your session at every page request.

Howdy, Stranger!

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

In this Discussion