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


PHP UserRepository::LoadByUsername方法代码示例

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


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

示例1: header

$params = array_merge($params, $_REQUEST);
if ($ikey != NULL && $ikey != $params['ikey']) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    print json_encode(array('message' => "your iKey is invalid", 'ikey' => $ikey, 'param_ikey' => $params['ikey']));
    return;
}
foreach (array('rn', 'username') as $key) {
    if (!$params[$key]) {
        header('HTTP/1.1 406 Not Acceptable', true, 406);
        print json_encode(array('message' => "{$key} has to be set"));
        return;
    }
}
$rn = $params['rn'];
$userRepo = new UserRepository();
$user = $userRepo->LoadByUsername($params['username']);
if ($user instanceof NullUser) {
    header('HTTP/1.1 403 Forbidden', true, 403);
    print json_encode(array('message' => "invalid userId"));
    return;
}
$user_session = new UserSession($user->Id());
// load resource by contact_info or rid
$resourceRepository = new ResourceRepository();
$contact_info = trim($_REQUEST['contact_info']);
$rid = trim($_REQUEST['rid']);
if ($contact_info && $rid) {
    header('HTTP/1.1 406 Not Acceptable', true, 406);
    print json_encode(array('message' => "You must not set both contact_info and rid"));
    return;
}
开发者ID:Trideon,项目名称:gigolo,代码行数:31,代码来源:update.php

示例2: Login

 public function Login($username, $loginContext)
 {
     $username = $this->CleanUsername($username);
     if ($this->LdapUserExists()) {
         $this->Synchronize($username);
     }
     $repo = new UserRepository();
     $user = $repo->LoadByUsername($username);
     $user->Deactivate();
     $user->Activate();
     $repo->Update($user);
     return $this->authToDecorate->Login($username, $loginContext);
 }
开发者ID:hugutux,项目名称:booked,代码行数:13,代码来源:Ldap.php

示例3: trim

$ends_at = $_REQUEST['ends_at'];
#$recurrence   = $_REQUEST['recurrence'];
$title = $_REQUEST['summary'];
$description = $_REQUEST['description'];
$contact_info = trim($_REQUEST['contact_info']);
$rid = trim($_REQUEST['rid']);
##$regexp_email = firstname.lastname@aaa.bbb.com;
$regexp_email = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}\$/";
if (preg_match($regexp_email, $contact_info)) {
    $contact_info = strtolower($contact_info);
}
/*************************************************
 	user information
 *************************************************/
$userRepository = new UserRepository();
$user = $userRepository->LoadByUsername($username);
if ($user instanceof NullUser) {
    header('HTTP/1.1 403 Forbidden', true, 403);
    print json_encode(array('message' => "invalid userId"));
    return;
}
$user_session = new UserSession($user->Id());
$user_session->Timezone = 'UTC';
/*************************************************
 	resources
 *************************************************/
$resourceRepository = new ResourceRepository();
if ($contact_info && $rid) {
    header('HTTP/1.1 406 Not Acceptable', true, 406);
    print json_encode(array('message' => "You must not set both contact_info and rid"));
    return;
开发者ID:Trideon,项目名称:gigolo,代码行数:31,代码来源:create.php

示例4: testCanLoadUserByUserName

 public function testCanLoadUserByUserName()
 {
     $userName = 'username';
     $userId = 982;
     $loginCommand = new LoginCommand(strtolower($userName));
     $loadEmailPreferencesCommand = new GetUserEmailPreferencesCommand($userId);
     $loadPermissionsCommand = new GetUserPermissionsCommand($userId);
     $loadGroupsCommand = new GetUserGroupsCommand($userId, null);
     $loadOwnedGroups = new GetGroupsIManageCommand($userId);
     $loadPreferences = new GetUserPreferencesCommand($userId);
     $userRow = $this->GetUserRow($userId);
     $emailPrefRows = $this->GetEmailPrefRows();
     $permissionsRows = $this->GetPermissionsRows();
     $groupsRows = $this->GetGroupsRows();
     $attributeRows = $this->GetAttributeRows();
     $ownedGroupRows = $this->GetOwnedGroupRows();
     $preferenceRows = $this->GetPreferenceRows();
     $this->db->SetRow(0, array($userRow));
     $this->db->SetRow(1, $emailPrefRows);
     $this->db->SetRow(2, $permissionsRows);
     $this->db->SetRow(3, $groupsRows);
     $this->db->SetRow(4, $attributeRows);
     $this->db->SetRow(5, $ownedGroupRows);
     $this->db->SetRow(6, $preferenceRows);
     $userRepository = new UserRepository();
     $user = $userRepository->LoadByUsername($userName);
     $this->assertEquals(7, count($this->db->_Commands));
     $this->assertTrue($this->db->ContainsCommand($loginCommand));
     $this->assertTrue($this->db->ContainsCommand($loadEmailPreferencesCommand));
     $this->assertTrue($this->db->ContainsCommand($loadPermissionsCommand));
     $this->assertTrue($this->db->ContainsCommand($loadGroupsCommand));
     $this->assertTrue($this->db->ContainsCommand($loadOwnedGroups));
     $this->assertTrue($this->db->ContainsCommand($loadPreferences));
     $this->assertEquals($userId, $user->Id());
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:35,代码来源:UserRepositoryTests.php


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