Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
SimpleAuth - multiple logins
  • Hi,

    I have a problem with setting up SimpleAuth with multiple_logins on. I have in my simpleauth.php config file

    'multiple_logins' => true,

    But still everytime I login on i.e. mobile I get logged out on desktop, etc. Is there anything else I need to do to make it work?
  • No.

    Auth keeps a login hash internally, and rejects a re-login via Auth::check() if the hash doesn't match. This check is disabled when 'multiple_logins' is set to true.

    This is checked in the auth\login\simpleauth.php class, in the perform_check() method. Perhaps you should debug that to see if it does what it must do.
  • Hi,

    I have a problem with setting up SimpleAuth with multiple_logins on. I have in my simpleauth.php config file

    'multiple_logins' => true,

    I want multiple login feature on. I should able to login from both mobile are also from PC at the same time.
    Their are multiple user login at the same time.
    how can i do this.. Please help 
  • What is exactly the problem, because I don't see any reason what that should not work.

    The simpleauth driver does

    // return true when login was verified, and either the hash matches or multiple logins are allowed
    if ($this->user and (\Config::get('simpleauth.multiple_logins', false) or $this->user['login_hash'] === $login_hash))
    {
        return true;
    }

    which means the login is valid if a user was found, and either multiple_logins is true or the login hash matches.
  • I think it should insert each login hash and use expire.


    * extend cp fuel/packages/auth/classes/auth/login/simpleauth.php fuel/app/classes/auth/login/simpleauth.php

    * modify fuel/app/classes/auth/login/simpleauth.php

    - create_login_hash()
    change from update to insert

    public function create_login_hash()
    //\DB::update(\Config::get('simpleauth.table_name'))
    \DB::insert(\Config::get('simpleauth.table_name'))
    ->set(array('last_login' => $last_login,
    'login_hash' => $login_hash,
    'username' => $this->user['username'],
    'password' => $this->user['password'],
    'group' => $this->user['group'],
    ))
    ->execute(\Config::get('simpleauth.db_connection'));


    - perform_check()
    add where login_has = $login_hash

    ->where('username', '=', $username)
    ->where('login_hash', '=', $login_hash)

    - login()
    add expire

    $yday = \Date::forge()->get_timestamp() - 86400;
    \DB::delete('users')->where('last_login','<',$yday)->and_where('username',$username_or_email)->execute();

  • I still don't see what the problem is.

    If you don't use the "multiple_logins" setting, the login-hash is used to prevent multiple logins. If you do use the setting (i.e. set it to true), the login-hash isn't used, and multiple logins of the same user is accepted.

    Storing multiple hashes doesn't add anything?
  • oh sorry, i misunderstood this
       app/config/auth.php
               verify_multiple_logins

    I confirmed multi login with this
      app/config/simpleauth.php
          'multiple_logins' => true,

  • ok.

    The first one means "verify against multiple auth drivers", the second one is a simpleauth driver setting.

Howdy, Stranger!

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

In this Discussion