/**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('zwacky/loginchecka', null, __DIR__ . '/..');
     // add config auth driver
     Loginchecka::extendConfigAuthDriver();
     include __DIR__ . '/filters.php';
     include __DIR__ . '/routes.php';
 }
示例#2
0
 /**
  * adds the config auth driver by using ConfigUserProvider.
  */
 public static function extendConfigAuthDriver()
 {
     if (!Loginchecka::$extended) {
         Auth::extend('config', function ($app) {
             $provider = new ConfigUserProvider();
             return new \Illuminate\Auth\Guard($provider, $app['session.store']);
         });
         Loginchecka::$extended = true;
     }
 }
示例#3
0
 public function testCheckConfig()
 {
     $username = '******';
     $password = '******';
     $auth = $this->app['auth'];
     $testLogins = array(array('username' => $username, 'password' => $password, 'shouldReturn' => true), array('username' => '', 'password' => '', 'shouldReturn' => false), array('username' => $username, 'password' => $password . 'noise', 'shouldReturn' => false));
     Loginchecka::extendConfigAuthDriver();
     Config::set('auth.driver', 'config');
     Config::set(Loginchecka::$CONFIG_IDENTIFIER, 'username');
     Config::set(Loginchecka::$CONFIG_LOGINS, array(array('username' => $username, 'password' => $password)));
     foreach ($testLogins as $test) {
         $res = $auth->attempt(array('username' => $test['username'], 'password' => $test['password']));
         $this->assertEquals($res, $test['shouldReturn']);
     }
 }