Пример #1
0
 public static function _init()
 {
     \Config::load('auth', true);
     // Whether to allow multiple drivers of any type, defaults to not allowed
     static::$_verify_multiple = \Config::get('auth.verify_multiple_logins', false);
     foreach ((array) \Config::get('auth.driver', array()) as $driver => $config) {
         $config = is_int($driver) ? array('driver' => $config) : array_merge($config, array('driver' => $driver));
         static::factory($config);
     }
     // set the first (or only) as the default instance for static usage
     if (!empty(static::$_instances)) {
         static::$_instance = reset(static::$_instances);
         static::check();
     }
 }
Пример #2
0
 /**
  * Load a login driver to the array of loaded drivers
  *
  * @param   Array  settings for the new driver
  * @throws  AuthException  on driver load failure
  */
 public static function forge($custom = array())
 {
     // Driver is given as array key or just string in custom
     $custom = !is_array($custom) ? array('driver' => $custom) : $custom;
     $config = \Config::get('auth.' . $custom['driver'] . '_config', array());
     $config = array_merge($config, $custom);
     // Driver must be set
     if (empty($config['driver']) || !is_string($config['driver'])) {
         throw new \AuthException('No auth driver given.');
     }
     // determine the driver to load
     $driver = \Auth_Login_Driver::forge($config);
     // get the driver's cookie name
     $id = $driver->get_id();
     // do we already have a driver instance for this cookie?
     if (isset(static::$_instances[$id])) {
         // if so, they must be using the same driver class!
         $class = get_class($driver);
         if (!static::$_instances[$id] instanceof $class) {
             throw new \AuthException('You can not instantiate two different login drivers using the same id "' . $id . '"');
         }
     } else {
         // store this instance
         static::$_instances[$id] = $driver;
     }
     // If we have more then one driver instance, check if we need concurrency
     if (count(static::$_instances) > 1) {
         // Whether to allow multiple drivers of any type, defaults to not allowed
         static::$_verify_multiple = \Config::get('auth.verify_multiple_logins', false);
     }
     return static::$_instances[$id];
 }