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


PHP User::setAsLoged方法代码示例

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


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

示例1: testsetAsLoged

 /**
  * @depends testCreate
  */
 public function testsetAsLoged()
 {
     $id = DM\Users::create(array('name' => $this->testName, 'password' => 'qq'));
     $this->assertTrue(is_numeric($id), 'Cant create User');
     \CB\User::setAsLoged($id, 'tests_key');
     $this->assertTrue(\CB\User::isLoged(), ' Error: user is not logged');
     $this->assertEquals($id, $_SESSION['user']['id'], 'Sessions user is not equal with setted users');
     $this->assertEquals('tests_key', $_SESSION['key'], 'Sessions key is not equal with setted keys');
 }
开发者ID:youprofit,项目名称:casebox,代码行数:12,代码来源:UserTest.php

示例2: init

 /**
  *
  * @param type $corename
  */
 public static function init($corename = DEFAULT_TEST_CORENAME)
 {
     $CB_PATH = \CB_DOC_ROOT;
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['SERVER_NAME'] = static::getHost();
     $_GET['core'] = $corename;
     $_SESSION['user'] = array('id' => 1, 'groups' => [1]);
     require_once $CB_PATH . '/config.php';
     require_once $CB_PATH . '/lib/language.php';
     L\initTranslations();
     Config::setEnvVar('user_language_index', 1);
     \CB\User::setAsLoged(1, 'AbrACadaBraK333y');
 }
开发者ID:youprofit,项目名称:casebox,代码行数:17,代码来源:Helpers.php

示例3: test_checkLogined

 /**
  * @depends test_getLoginUrl
  */
 public function test_checkLogined()
 {
     unset($_SESSION['key']);
     $this->assertFalse(\CB\User::isLoged(), 'ERROR checkLogined \\CB\\Users::isLoged = true');
     $url = $this->getUrl();
     $this->assertTrue(isset($url), 'ERROR checkLogined getGoogleLoginUrl ' . $url);
     $uri = parse_url($url);
     $Oauth2Query = [];
     parse_str($uri['query'], $Oauth2Query);
     $_GET = $Oauth2Query;
     $state = \CB\Oauth2Utils::decodeState($Oauth2Query['state']);
     $state['email'] = $this->email;
     $_GET['state'] = \CB\Oauth2Utils::encodeState($state);
     $check = \CB\Oauth2Utils::checkLogined();
     $this->assertTrue($check['success'], '\\CB\\Oauth2Utils::checkLogined() return success false');
     $this->assertTrue($check['user_id'] == 1, '\\CB\\Oauth2Utils::checkLogined() WRONG USER ID');
     $this->assertTrue($check['session_id'] == $state['state'], '\\CB\\Oauth2Utils::checkLogined() WRON SESSION ID');
     $r = \CB\User::setAsLoged($check['user_id'], $check['session_id']);
     $this->assertTrue($r['success'], ' User can\'t be set as logined');
 }
开发者ID:youprofit,项目名称:casebox,代码行数:23,代码来源:Oauth2UtilsTest.php

示例4: checkLastNotification

 /**
  * check if last notification for a user
  * is from userId, for objectId
  * @param  int   $userId
  * @param  array $matches array containing properties to match with
  * @return bool
  */
 protected function checkLastNotification($userId, $matches)
 {
     $rez = false;
     //save current user id
     $currentUser = $_SESSION['user']['id'];
     \CB\User::setAsLoged($userId, $_SESSION['key']);
     //$_SESSION['user']['id'] = $userId;
     $api = new \CB\Api\Notifications();
     //check if counts are not empty
     $countResult = $api->getNew(array());
     if ($countResult['success'] !== true || empty($countResult['data'])) {
         trigger_error(print_r($countResult, true), E_USER_ERROR);
         return $rez;
     }
     //check the last notification with given $matches
     $n = $this->getLastNotification($userId);
     if (!empty($n)) {
         $rez = true;
         foreach ($matches as $k => $v) {
             $rez = $rez && $n[$k] == $v;
         }
     }
     //restore previous user id
     //$_SESSION['user']['id'] = $currentUser;
     \CB\User::setAsLoged($currentUser, $_SESSION['key']);
     if (!$rez) {
         trigger_error(print_r($n, true), E_USER_ERROR);
     }
     return $rez;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:37,代码来源:NotificationsTest.php


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