コード例 #1
0
 public function authenticate(array $parameters = [])
 {
     if ($this->isAuthorized()) {
         return $this;
     }
     foreach (array_keys($this->authConfig['providers']) as $idpid) {
         $this->storage->delete("{$idpid}.hauth_return_to");
         $this->storage->delete("{$idpid}.hauth_endpoint");
         $this->storage->delete("{$idpid}.id_provider_params");
     }
     $this->storage->deleteMatch("{$this->providerId}.");
     $baseUrl = $this->authConfig['base_url'];
     $defaults = array('hauth_return_to' => Util::getCurrentUrl(), 'hauth_endpoint' => $baseUrl . (strpos($baseUrl, '?') ? '&' : '?') . "hauth.done={$this->providerId}", 'hauth_start_url' => $baseUrl . (strpos($baseUrl, '?') ? '&' : '?') . "hauth.start={$this->providerId}&hauth.time=" . time());
     $parameters = array_merge($defaults, (array) $parameters);
     $this->storage->set($this->providerId . '.hauth_return_to', $parameters['hauth_return_to']);
     $this->storage->set($this->providerId . '.hauth_endpoint', $parameters['hauth_endpoint']);
     $this->storage->set($this->providerId . '.id_provider_params', $parameters);
     // redirect user to start url
     Util::redirect($parameters['hauth_start_url']);
 }