/** * Execute the console command. * * @return mixed */ public function handle() { $attributes = ['id' => $this->option('id') ?: SecureKey::generate(), 'secret' => $this->option('secret') ?: SecureKey::generate(), 'name' => $this->argument('name'), 'redirect_uri' => $this->argument('redirect-uri')]; $newClient = Client::create($attributes); $this->info("Your new client has been created!"); $this->info(sprintf("Client name : %s", $newClient->getName())); $this->info(sprintf("Client ID : %s", $newClient->getId())); $this->info(sprintf("Client secret : %s", $newClient->getSecret())); $this->info(sprintf("Client URI : %s", $newClient->getRedirectUri())); }
/** * Find a client by criteria. * * @param string $id The client's ID * @param string $secret The client's secret (default = "null") * @param string $redirectUri The client's redirect URI (default = "null") * @param string $grantType The grant type used (default = "null") * @return \Atrauzzi\Oauth2Server\Domain\Entity\Client */ public function find($id, $secret = null, $grantType = null, $redirectUri = null) { $query = EloquentClient::query(); if ($id) { $query->where('id', $id); } if ($secret) { $query->where('secret', $secret); } // ToDo: Support matching by grant. if ($redirectUri) { $query->where('redirect_uri', $redirectUri); } return $query->first(); }