Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
auth check not workin
  • hi \Auth::check() is not working in the driver i have created. Login is sucessfull but after the user is logged out it is not checking and allowing user to go back.
     if (!\Auth\Auth::check()) {
                    \Auth\Auth::logout();
                    \Response::redirect('login/loginform');
                }
    
  • The result of Auth::check() is produced by the perform_check() method in your own Auth driver, so I suggest you start by checking if that works as it should.
  • hi WW after login it goes back but if it is refreshed then it again goes and ask for login. it think page isnt refreshed or got problem with anything else
  • Must be a logic error in your driver, there is no logic in the Auth interface or the generic login driver that deals with login/logout state. How do you set the login state? Maybe a cookie or session issue?
  • Make sure though you're not calling perform_check() or logout() directly on the driver, there's logic in Auth_Login_Driver::check() and Auth::logout() that's required for it to login & logout correctly.
  • Harro Verton wrote on Sunday 11th of September 2011:
    Must be a logic error in your driver, there is no logic in the Auth interface or the generic login driver that deals with login/logout state. How do you set the login state? Maybe a cookie or session issue?

    i have used session
    here is the code
    public function perform_check()
     {
      $username    = \Session::get('user');
      $login_hash  = \Session::get('login_hash');
         
      if (is_null($this->user) or ($this->user[\Config::get('username')] != $username and $this->user != static::$guest_login))
      {
       $this->user = \DB::select()
        ->where(\Config::get('username'), '=', $username)
        ->from(static::$table_name)
        ->execute()->current();
      }
    
      if ($this->user and $this->user['login_hash'] === $login_hash)
      {
       return true;
      }
          $this->user = \Config::get('guest_login', true) ? static::$guest_login : false;
      \Session::delete('username');
      \Session::delete('login_hash');
    
      return false;
     }
    
  • Time to debug that logic. An obvious candidate this the login_hash check.

Howdy, Stranger!

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

In this Discussion