本文整理汇总了PHP中PhabricatorUser::hasSession方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorUser::hasSession方法的具体用法?PHP PhabricatorUser::hasSession怎么用?PHP PhabricatorUser::hasSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorUser
的用法示例。
在下文中一共展示了PhabricatorUser::hasSession方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeNewLog
public static function initializeNewLog(PhabricatorUser $actor = null, $object_phid = null, $action = null)
{
$log = new PhabricatorUserLog();
if ($actor) {
$log->setActorPHID($actor->getPHID());
if ($actor->hasSession()) {
$session = $actor->getSession();
// NOTE: This is a hash of the real session value, so it's safe to
// store it directly in the logs.
$log->setSession($session->getSessionKey());
}
}
$log->setUserPHID((string) $object_phid);
$log->setAction($action);
$log->remoteAddr = (string) idx($_SERVER, 'REMOTE_ADDR', '');
return $log;
}
示例2: isExtensionEnabledForViewer
public function isExtensionEnabledForViewer(PhabricatorUser $viewer)
{
if (!$viewer->isLoggedIn()) {
return false;
}
if (!$viewer->isUserActivated()) {
return false;
}
// Don't show menus for users with partial sessions. This usually means
// they have logged in but have not made it through MFA, so we don't want
// to show notification counts, saved queries, etc.
if (!$viewer->hasSession()) {
return false;
}
if ($viewer->getSession()->getIsPartial()) {
return false;
}
return true;
}
示例3: signLegalpadDocuments
/**
* Upgrade a session to have all legalpad documents signed.
*
* @param PhabricatorUser User whose session should upgrade.
* @param array LegalpadDocument objects
* @return void
* @task partial
*/
public function signLegalpadDocuments(PhabricatorUser $viewer, array $docs)
{
if (!$viewer->hasSession()) {
throw new Exception(pht('Signing session legalpad documents of user with no session!'));
}
$session = $viewer->getSession();
if ($session->getSignedLegalpadDocuments()) {
throw new Exception(pht('Session has already signed required legalpad documents!'));
}
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$session->setSignedLegalpadDocuments(1);
queryfx($session->establishConnection('w'), 'UPDATE %T SET signedLegalpadDocuments = %d WHERE id = %d', $session->getTableName(), 1, $session->getID());
if (!empty($docs)) {
$log = PhabricatorUserLog::initializeNewLog($viewer, $viewer->getPHID(), PhabricatorUserLog::ACTION_LOGIN_LEGALPAD);
$log->save();
}
unset($unguarded);
}
示例4: upgradePartialSession
/**
* Upgrade a partial session to a full session.
*
* @param PhabricatorAuthSession Session to upgrade.
* @return void
* @task partial
*/
public function upgradePartialSession(PhabricatorUser $viewer)
{
if (!$viewer->hasSession()) {
throw new Exception(pht('Upgrading partial session of user with no session!'));
}
$session = $viewer->getSession();
if (!$session->getIsPartial()) {
throw new Exception(pht('Session is not partial!'));
}
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$session->setIsPartial(0);
queryfx($session->establishConnection('w'), 'UPDATE %T SET isPartial = %d WHERE id = %d', $session->getTableName(), 0, $session->getID());
$log = PhabricatorUserLog::initializeNewLog($viewer, $viewer->getPHID(), PhabricatorUserLog::ACTION_LOGIN_FULL);
$log->save();
unset($unguarded);
}