当前位置: 首页>>代码示例>>PHP>>正文


PHP ISession::exists方法代码示例

本文整理汇总了PHP中OCP\ISession::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP ISession::exists方法的具体用法?PHP ISession::exists怎么用?PHP ISession::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\ISession的用法示例。


在下文中一共展示了ISession::exists方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkSession

 /**
  * Makes sure the user is already properly authenticated when a password is required and none
  * was provided
  *
  * @param IShare $share
  *
  * @throws CheckException
  */
 private function checkSession($share)
 {
     // Not authenticated ?
     if (!$this->session->exists('public_link_authenticated') || $this->session->get('public_link_authenticated') !== (string) $share->getId()) {
         throw new CheckException("Missing password", Http::STATUS_UNAUTHORIZED);
     }
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:15,代码来源:envcheckmiddleware.php

示例2: getTimeZone

 /**
  * Get the timezone of the current user, based on his session information and config data
  *
  * @param bool|int $timestamp
  * @return \DateTimeZone
  */
 public function getTimeZone($timestamp = false)
 {
     $timeZone = $this->config->getUserValue($this->session->get('user_id'), 'core', 'timezone', null);
     if ($timeZone === null) {
         if ($this->session->exists('timezone')) {
             return $this->guessTimeZoneFromOffset($this->session->get('timezone'), $timestamp);
         }
         $timeZone = $this->getDefaultTimeZone();
     }
     try {
         return new \DateTimeZone($timeZone);
     } catch (\Exception $e) {
         \OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", \OCP\Util::DEBUG);
         return new \DateTimeZone($this->getDefaultTimeZone());
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:22,代码来源:DateTimeZone.php

示例3: checkSession

 /**
  * Makes sure the user is already properly authenticated when a password is required and none
  * was provided
  *
  * @param array|bool $linkItem
  *
  * @throws CheckException
  */
 private function checkSession($linkItem)
 {
     // Not authenticated ?
     if (!$this->session->exists('public_link_authenticated') || $this->session->get('public_link_authenticated') !== $linkItem['id']) {
         throw new CheckException("Missing password", Http::STATUS_UNAUTHORIZED);
     }
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:15,代码来源:envcheckmiddleware.php

示例4: getTimeZone

 /**
  * Get the timezone of the current user, based on his session information and config data
  *
  * @return \DateTimeZone
  */
 public function getTimeZone()
 {
     $timeZone = $this->config->getUserValue($this->session->get('user_id'), 'core', 'timezone', null);
     if ($timeZone === null) {
         if ($this->session->exists('timezone')) {
             $offsetHours = $this->session->get('timezone');
             // Note: the timeZone name is the inverse to the offset,
             // so a positive offset means negative timeZone
             // and the other way around.
             if ($offsetHours > 0) {
                 return new \DateTimeZone('Etc/GMT-' . $offsetHours);
             } else {
                 return new \DateTimeZone('Etc/GMT+' . abs($offsetHours));
             }
         } else {
             return new \DateTimeZone('UTC');
         }
     }
     return new \DateTimeZone($timeZone);
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:25,代码来源:datetimezone.php

示例5: validateUserPass

 /**
  * Validates a username and password
  *
  * This method should return true or false depending on if login
  * succeeded.
  *
  * @param string $username
  * @param string $password
  *
  * @return bool
  * @throws \Sabre\DAV\Exception\NotAuthenticated
  */
 protected function validateUserPass($username, $password)
 {
     try {
         $share = $this->shareManager->getShareByToken($username);
     } catch (ShareNotFound $e) {
         return false;
     }
     $this->share = $share;
     \OC_User::setIncognitoMode(true);
     // check if the share is password protected
     if ($share->getPassword() !== null) {
         if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
             if ($this->shareManager->checkPassword($share, $password)) {
                 return true;
             } else {
                 if ($this->session->exists('public_link_authenticated') && $this->session->get('public_link_authenticated') === $share->getId()) {
                     return true;
                 } else {
                     if (in_array('XMLHttpRequest', explode(',', $this->request->getHeader('X-Requested-With')))) {
                         // do not re-authenticate over ajax, use dummy auth name to prevent browser popup
                         http_response_code(401);
                         header('WWW-Authenticate', 'DummyBasic real="ownCloud"');
                         throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
                     }
                     return false;
                 }
             }
         } else {
             if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
                 return true;
             } else {
                 return false;
             }
         }
     } else {
         return true;
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:50,代码来源:publicauth.php

示例6: linkShareAuth

 /**
  * Authenticate a link item with the given password.
  * Or use the session if no password is provided.
  *
  * This is a modified version of Helper::authenticate
  * TODO: Try to merge back eventually with Helper::authenticate
  *
  * @param \OCP\Share\IShare $share
  * @param string|null $password
  * @return bool
  */
 private function linkShareAuth(\OCP\Share\IShare $share, $password = null)
 {
     if ($password !== null) {
         if ($this->shareManager->checkPassword($share, $password)) {
             $this->session->set('public_link_authenticated', (string) $share->getId());
         } else {
             return false;
         }
     } else {
         // not authenticated ?
         if (!$this->session->exists('public_link_authenticated') || $this->session->get('public_link_authenticated') !== (string) $share->getId()) {
             return false;
         }
     }
     return true;
 }
开发者ID:Pookay,项目名称:core,代码行数:27,代码来源:sharecontroller.php

示例7: showChallenge

 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @UseSession
  *
  * @param string $challengeProviderId
  * @param string $redirect_url
  * @return TemplateResponse
  */
 public function showChallenge($challengeProviderId, $redirect_url)
 {
     $user = $this->userSession->getUser();
     $provider = $this->twoFactorManager->getProvider($user, $challengeProviderId);
     if (is_null($provider)) {
         return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge'));
     }
     if ($this->session->exists('two_factor_auth_error')) {
         $this->session->remove('two_factor_auth_error');
         $error = true;
     } else {
         $error = false;
     }
     $tmpl = $provider->getTemplate($user);
     $tmpl->assign('redirect_url', $redirect_url);
     $data = ['error' => $error, 'provider' => $provider, 'logout_attribute' => $this->getLogoutAttribute(), 'template' => $tmpl->fetchPage()];
     return new TemplateResponse($this->appName, 'twofactorshowchallenge', $data, 'guest');
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:27,代码来源:TwoFactorChallengeController.php

示例8: hasToken

 /**
  * Whether the storage has a storage.
  *
  * @return bool
  */
 public function hasToken()
 {
     return $this->session->exists('requesttoken');
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:9,代码来源:SessionStorage.php

示例9: needsSecondFactor

 /**
  * Check if the currently logged in user needs to pass 2FA
  *
  * @return boolean
  */
 public function needsSecondFactor()
 {
     return $this->session->exists(self::SESSION_UID_KEY);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:9,代码来源:Manager.php

示例10: exists

 /**
  * Check if a named key exists in the session
  *
  * @param string $key
  * @return bool
  */
 public function exists($key)
 {
     return $this->session->exists($key);
 }
开发者ID:rosarion,项目名称:core,代码行数:10,代码来源:cryptosessiondata.php


注:本文中的OCP\ISession::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。