Esempio n. 1
0
 public function doLogout()
 {
     $options = new ezcAuthenticationSessionOptions();
     $options->validity = 86400;
     $session = new ezcAuthenticationSession($options);
     $session->start();
     $session->destroy();
     $res = new ezcMvcResult();
     $res->status = new ezcMvcExternalRedirect('/');
     return $res;
 }
// no headers should be sent before calling $session->start()
$options = new ezcAuthenticationSessionOptions();
$session = new ezcAuthenticationSession($options);
$session->start();
// URL after returning from OpenID authentication
$url = isset($_GET['openid_identity']) ? $_GET['openid_identity'] : $session->load();
if ($url === null) {
    // URL at the start of authentication
    $url = isset($_GET['openid_identifier']) ? $_GET['openid_identifier'] : $session->load();
}
$action = isset($_GET['action']) ? strtolower($_GET['action']) : null;
$credentials = new ezcAuthenticationIdCredentials($url);
$authentication = new ezcAuthentication($credentials);
$authentication->session = $session;
if ($action === 'logout') {
    $session->destroy();
} else {
    $options = new ezcAuthenticationOpenidOptions();
    $options->mode = ezcAuthenticationOpenidFilter::MODE_SMART;
    $options->openidVersion = ezcAuthenticationOpenidFilter::VERSION_2_0;
    $options->store = new ezcAuthenticationOpenidFileStore('/tmp/store');
    $filter = new ezcAuthenticationOpenidFilter($options);
    $filter->registerFetchData(array('fullname', 'gender', 'country', 'language'));
    $authentication->addFilter($filter);
}
if (!$authentication->run()) {
    // authentication did not succeed, so inform the user
    $status = $authentication->getStatus();
    $err = array();
    $err["user"] = "";
    $err["session"] = "";
Esempio n. 3
0
 /**
  * Method to be called from the controller's logout action to log a user out.
  *
  * @param ezcMvcRequest $request
  */
 public function logout(ezcMvcRequest $request)
 {
     $options = new ezcAuthenticationSessionOptions();
     $options->validity = 86400;
     $session = new ezcAuthenticationSession($options);
     $session->start();
     unset($_SESSION[$this->options->sessionUserIdKey]);
     $session->destroy();
 }