/** * Identify client identifed from current request. * * @return array */ private function identifyClientFromRequest() { $clientId = $this->getRequest()->input('client_id', ''); $clientSecret = $this->getRequest()->input('client_secret', null); $redirectUri = $this->getRequest()->input('redirect_uri', null); try { $this->accessToken = $this->getResource()->determineAccessToken(); $sessionRepository = new FluentSession(); $sesion = $sessionRepository->validateAccessToken($this->accessToken); if ($sesion !== false) { $clientId = $sesion['client_id']; $clientSecret = $sesion['client_secret']; } unset($sessionRepository); unset($sesion); } catch (InvalidAccessTokenException $e) { } if (!empty($clientId)) { $clientRepository = new FluentClient(); $client = $clientRepository->getClient($clientId, $clientSecret, $redirectUri); if ($client !== false) { $client['id'] = $clientId; $client['secret'] = $client['client_secret']; unset($client['client_id']); unset($client['client_secret']); unset($client['redirect_uri']); unset($client['metadata']); $this->client = new OauthClient(); $this->client->fill($client); $this->client->exists = true; $this->client->syncOriginal(); } unset($client); unset($clientRepository); } unset($clientId); unset($clientSecret); unset($redirectUri); }
/** * Execute the console command. * * @return void */ public function fire() { $clientName = $this->argument('name'); $clientId = $this->option('id'); $clientSecret = $this->option('secret'); if (empty($clientId)) { $clientId = Str::random(40); } if (empty($clientSecret)) { $clientSecret = Str::random(40); } $oAuthClient = OauthClient::create(array('id' => $clientId, 'secret' => $clientSecret, 'name' => $clientName)); if ($oAuthClient->exists) { $this->info('Client Name: ' . $clientName); $this->info('Client Id: ' . $clientId); $this->info('Client Secret: ' . $clientSecret); $this->info('Created'); } else { $this->error('Client Name: ' . $clientName); $this->error('Failed'); } }