當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::logout方法代碼示例

本文整理匯總了PHP中OCP\User::logout方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::logout方法的具體用法?PHP User::logout怎麽用?PHP User::logout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OCP\User的用法示例。


在下文中一共展示了User::logout方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postlogin_hook

 /**
  * Send JSON response on successful login
  * @param String $uid
  */
 public static function postlogin_hook($uid)
 {
     if (!self::$_isPersona) {
         return;
     }
     \OCP\Util::writeLog(App::APP_ID, 'Check ambigous ', \OCP\Util::DEBUG);
     if (self::$_isAmbigous) {
         //Reply with error and logout
         \OCP\User::logout();
         \OCP\JSON::error(array('msg' => 'More than one user found'));
         exit;
     } else {
         \OCP\JSON::success(array('msg' => 'Access granted'));
         exit;
     }
 }
開發者ID:DOM-Digital-Online-Media,項目名稱:apps,代碼行數:20,代碼來源:validator.php

示例2: postLogin

 /**
  * Action after user's authentification : if he is on the rejected group, he is logout and redirect to main page
  *
  * @author Victor Bordage-Gorry <victor.bordage-gorry@globalis-ms.com>
  * @copyright 2015 CNRS DSI / GLOBALIS media systems
  *
  */
 public function postLogin()
 {
     // Verify default group
     $defaultGroup = $this->config->getSystemValue('deletion_account_request_default_exclusion_group');
     if ($this->groupManager->get($defaultGroup)->searchUsers(\OCP\User::getUser())) {
         \OCP\User::logout();
         \OC_Util::redirectToDefaultPage();
         exit;
     }
     // Verify configuration groups
     $configGroups = $this->config->getSystemValue('deletion_account_request_exclusion_groups');
     if (!empty($configGroups)) {
         foreach ($configGroups as $groupKey => $groupValue) {
             if ($this->groupManager->get($groupValue) && $this->groupManager->get($groupValue)->searchUsers(\OCP\User::getUser())) {
                 \OCP\User::logout();
                 \OC_Util::redirectToDefaultPage();
                 exit;
             }
         }
     }
 }
開發者ID:CNRS-DSI-Dev,項目名稱:user_deletion_request,代碼行數:28,代碼來源:userhooks.php

示例3: login

 /**
  * @brief Startup encryption backend upon user login
  * @note This method should never be called for users using client side encryption
  */
 public static function login($params)
 {
     if (\OCP\App::isEnabled('files_encryption') === false) {
         return true;
     }
     $l = new \OC_L10N('files_encryption');
     $view = new \OC_FilesystemView('/');
     // ensure filesystem is loaded
     if (!\OC\Files\Filesystem::$loaded) {
         \OC_Util::setupFS($params['uid']);
     }
     $privateKey = \OCA\Encryption\Keymanager::getPrivateKey($view, $params['uid']);
     // if no private key exists, check server configuration
     if (!$privateKey) {
         //check if all requirements are met
         if (!Helper::checkRequirements() || !Helper::checkConfiguration()) {
             $error_msg = $l->t("Missing requirements.");
             $hint = $l->t('Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled.');
             \OC_App::disable('files_encryption');
             \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR);
             \OCP\Template::printErrorPage($error_msg, $hint);
         }
     }
     $util = new Util($view, $params['uid']);
     // setup user, if user not ready force relogin
     if (Helper::setupUser($util, $params['password']) === false) {
         return false;
     }
     $session = $util->initEncryption($params);
     // Check if first-run file migration has already been performed
     $ready = false;
     $migrationStatus = $util->getMigrationStatus();
     if ($migrationStatus === Util::MIGRATION_OPEN && $session !== false) {
         $ready = $util->beginMigration();
     } elseif ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {
         // refuse login as long as the initial encryption is running
         sleep(5);
         \OCP\User::logout();
         return false;
     }
     // If migration not yet done
     if ($ready) {
         $userView = new \OC_FilesystemView('/' . $params['uid']);
         // Set legacy encryption key if it exists, to support
         // depreciated encryption system
         if ($userView->file_exists('encryption.key') && ($encLegacyKey = $userView->file_get_contents('encryption.key'))) {
             $plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']);
             $session->setLegacyKey($plainLegacyKey);
         }
         // Encrypt existing user files
         try {
             $result = $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password']);
         } catch (\Exception $ex) {
             \OCP\Util::writeLog('Encryption library', 'Initial encryption failed! Error: ' . $ex->getMessage(), \OCP\Util::FATAL);
             $util->resetMigrationStatus();
             \OCP\User::logout();
             $result = false;
         }
         if ($result) {
             \OC_Log::write('Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed', \OC_Log::INFO);
             // Register successful migration in DB
             $util->finishMigration();
         }
     }
     return true;
 }
開發者ID:hjimmy,項目名稱:owncloud,代碼行數:70,代碼來源:hooks.php

示例4: header

    if (sizeof($users) !== 1) {
        // User not found
        header('HTTP/1.0 404 Not Found');
        exit;
    }
    // Token found login as that user
    \OC_User::setUserId(array_shift($users));
    $forceUserLogout = true;
}
// check if the user has the right permissions.
\OCP\User::checkLoggedIn();
// rss is of content type text/xml
if (isset($_SERVER['HTTP_ACCEPT']) && stristr($_SERVER['HTTP_ACCEPT'], 'application/rss+xml')) {
    header('Content-Type: application/rss+xml');
} else {
    header('Content-Type: text/xml; charset=UTF-8');
}
// generate and show the rss feed
$l = \OCP\Util::getL10N('activity');
$data = new \OCA\Activity\Data(\OC::$server->getActivityManager());
$groupHelper = new \OCA\Activity\GroupHelper(\OC::$server->getActivityManager(), new \OCA\Activity\DataHelper(\OC::$server->getActivityManager(), new \OCA\Activity\ParameterHelper(new \OC\Files\View(''), \OC::$server->getConfig(), $l), $l), false);
$tmpl = new \OCP\Template('activity', 'rss');
$tmpl->assign('rssLang', \OC_Preferences::getValue(\OCP\User::getUser(), 'core', 'lang'));
$tmpl->assign('rssLink', \OC::$server->getURLGenerator()->getAbsoluteURL(\OC::$server->getURLGenerator()->linkToRoute('activity.rss')));
$tmpl->assign('rssPubDate', date('r'));
$tmpl->assign('user', \OCP\User::getUser());
$tmpl->assign('activities', $data->read($groupHelper, 0, 30, 'all'));
$tmpl->printPage();
if ($forceUserLogout) {
    \OCP\User::logout();
}
開發者ID:droiter,項目名稱:openwrt-on-android,代碼行數:31,代碼來源:rss.php

示例5: logout

 /**
  * @brief Loggs the user out including all the session data
  * Logout, destroys session
  */
 public function logout()
 {
     return \OCP\User::logout();
 }
開發者ID:hjimmy,項目名稱:owncloud,代碼行數:8,代碼來源:api.php

示例6: mailDeleteAccount

 /**
  * Adds the user to the reject group and send an email to the administrator to inform them of the request for deletion
  *
  * @author Victor Bordage-Gorry <victor.bordage-gorry@globalis-ms.com>
  * @copyright 2015 CNRS DSI / GLOBALIS media systems
  *
  * @param     string   $requesterUid    User's Uid
  */
 public function mailDeleteAccount($requesterUid)
 {
     $reason = trim(strip_tags(stripslashes($_POST['deletion_reason'])));
     if (empty($reason) || $reason === '') {
         return false;
     }
     // User modification, add to rejected group
     $user = $this->userManager->get($requesterUid);
     $userGroups = $this->groupManager->getUserGroupIds($user);
     // get the user's exclusion group.
     $configGroups = $this->config->getSystemValue('deletion_account_request_exclusion_groups');
     if (is_array($configGroups)) {
         foreach ($configGroups as $groupKey => $groupValue) {
             if (in_array($groupKey, $userGroups)) {
                 if ($this->groupManager->groupExists($groupValue)) {
                     $group = $this->groupManager->get($groupValue);
                 } else {
                     $group = $this->groupManager->createGroup($groupValue);
                 }
                 break;
             }
         }
     }
     // if $group unset, we use the default value
     if (empty($group)) {
         $val = $this->config->getSystemValue('deletion_account_request_default_exclusion_group');
         if ($this->groupManager->groupExists($val)) {
             $group = $this->groupManager->get($val);
         } else {
             $group = $this->groupManager->createGroup($val);
         }
     }
     $group->addUser($user);
     // get the admin's mail
     $configMails = $this->config->getSystemValue('deletion_account_request_admin_emails');
     if (is_array($configMails)) {
         foreach ($configMails as $mailKey => $mailValue) {
             if (in_array($mailKey, $userGroups)) {
                 $toAddress = $toName = $mailValue;
                 break;
             }
         }
     }
     // if $toAdress unset, we use the default value
     if (empty($toAdress)) {
         $toAddress = $toName = $this->config->getSystemValue('deletion_account_request_default_admin_email');
     }
     // Mail part
     $theme = new \OC_Defaults();
     $subject = (string) $this->l->t('Request for deleting account: %s', array($requesterUid));
     // generate the content
     $html = new \OCP\Template($this->appName, "mail_userdeletion_html", "");
     $html->assign('overwriteL10N', $this->l);
     $html->assign('requesterUid', $requesterUid);
     $html->assign('reason', $_POST['deletion_reason']);
     $htmlMail = $html->fetchPage();
     $alttext = new \OCP\Template($this->appName, "mail_userdeletion_text", "");
     $alttext->assign('overwriteL10N', $this->l);
     $alttext->assign('requesterUid', $requesterUid);
     $alttext->assign('reason', $reason);
     $altMail = $alttext->fetchPage();
     $fromAddress = $fromName = \OCP\Util::getDefaultEmailAddress('owncloud');
     //sending
     try {
         \OCP\Util::sendMail($toAddress, $toName, $subject, $htmlMail, $fromAddress, $fromName, 1, $altMail);
     } catch (\Exception $e) {
         \OCP\Util::writeLog('user_account_actions', "Can't send mail for user creation: " . $e->getMessage(), \OCP\Util::ERROR);
     }
     // logout and redirect
     \OCP\User::logout();
     \OC_Util::redirectToDefaultPage();
     exit;
 }
開發者ID:Victor-Bordage-Gorry,項目名稱:user_deletion_request,代碼行數:81,代碼來源:mailservice.php


注:本文中的OCP\User::logout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。