app['auth']->provider('custom_database', function() { return new AppUserProvider(DB::connection(), $this->app['hash'], 'user'); });*/ } /** * Boot the authentication services for the application. * * @return void */ public function boot() { $auth = app('auth'); $reflClass = new \ReflectionClass($auth); $reflProp = $reflClass->getProperty('guards'); $reflProp->setAccessible(true); $reflProp->setValue($auth, []); $reflProp = $reflClass->getProperty('customCreators'); $reflProp->setAccessible(true); $reflProp->setValue($auth, []); $this->app['auth']->viaRequest('api', function ($request) { checkRedisPing(); $token = $request->header('token'); $token_update_time= config('cache.token_update_time'); if(empty($token)){ $token = $request->input('token'); } if ($token) { $data = SysAdminUserFacade::findOneByToken($token); if (!empty($data)) { //超过半小时 发送heartbeat $time=time(); if ($data['expiration_time'] <($time + $token_update_time)) { $data = SysAdminUserFacade::updateUserInfoCache($token, $data); } return $data; } } return null; }); } }