Example #1
0
 public function testSaveAndLoadGroup()
 {
     $u = array();
     for ($i = 0; $i < 5; $i++) {
         $user = new User();
         $user->setScenario('createUser');
         $user->username = "******";
         $user->title->value = 'Mr.';
         $user->firstName = "Uuuuuu{$i}";
         $user->lastName = "Uuuuuu{$i}son";
         $user->setPassword("uuuuu{$i}");
         $this->assertTrue($user->save());
         // Clear cache of user so the groups properly get accounted for later.
         // This was needed after we added isActive which calls save twice when a user is
         // created
         $id = $user->id;
         $user->forget();
         $u[] = User::getById($id);
     }
     $a = new Group();
     $a->name = 'AAA';
     $this->assertTrue($a->save());
     $this->assertEquals(0, $a->users->count());
     $this->assertEquals(0, $a->groups->count());
     $b = new Group();
     $b->name = 'BBB';
     $this->assertTrue($b->save());
     $this->assertEquals(0, $b->users->count());
     $this->assertEquals(0, $b->groups->count());
     $a->users->add($u[0]);
     $a->groups->add($b);
     $this->assertTrue($a->save());
     $this->assertEquals(1, $a->users->count());
     $b->forget();
     unset($b);
     $a->forget();
     unset($a);
 }
Example #2
0
 public function testCreateNewUserFromPostNoBadValues()
 {
     $_FAKEPOST = array('UserPasswordForm' => array('title' => array('value' => ''), 'firstName' => 'Red', 'lastName' => 'Jiambo', 'username' => 'redjiambo', 'newPassword' => '123456', 'newPassword_repeat' => '123456', 'jobTitle' => '', 'officePhone' => '', 'manager' => array('id' => ''), 'mobilePhone' => '', 'department' => '', 'primaryEmail' => array('emailAddress' => '', 'optOut' => 0, 'isInvalid' => 0), 'primaryAddress' => array('street1' => '', 'street2' => '', 'city' => '', 'state' => '', 'postalCode' => '', 'country' => '')));
     $user = new User();
     $user->setScenario('createUser');
     $userPasswordForm = new UserPasswordForm($user);
     $userPasswordForm->setScenario('createUser');
     $userPasswordForm->setAttributes($_FAKEPOST['UserPasswordForm']);
     $userPasswordForm->validate();
     $this->assertEquals(array(), $userPasswordForm->getErrors());
     $this->assertTrue($userPasswordForm->save());
     $user->forget();
     $user = User::getByUsername('redjiambo');
     $this->assertEquals('Red', $user->firstName);
     $this->assertEquals(null, $user->officePhone);
     $this->assertEquals(null, $user->jobTitle);
     $this->assertEquals(null, $user->mobilePhone);
     $this->assertEquals(null, $user->department);
 }
Example #3
0
<?php

session_start();
include_once '/var/www/html/site/lib/config.php';
include_once LIB_DIR . "/helpers.php";
include_once LIB_DIR . "/router.php";
include_once LIB_DIR . "/dbconnect.php";
include_once LIB_DIR . "/convertString.ini.php";
include_once LIB_DIR . "/ini.php";
include_once BASE_DIR . "/model/user.php";
//$app = new AppIni;
$c = new User();
if ($_POST['type'] == 'login') {
    $c->home();
} elseif ($_POST['type'] == 'forget') {
    $c->forget();
} elseif ($_POST['type'] == 'forgetnickname') {
    $c->forgetnickname();
} elseif ($_POST['type'] == 'logAff') {
    $c->logAffiliate();
} elseif ($_POST['type'] == 'nicknamechange') {
    $c->nicknamechange();
} else {
    if (empty($_SESSION['auth_id'])) {
        //'请先登入会员账号'
        $ret['status'] = 1;
        echo json_encode($ret);
        exit;
    } else {
        if ($_POST['type'] == 'profile') {
            $c->profile();
Example #4
0
 static function forget(User $user)
 {
     $user->forget();
     setcookie("userId", '');
     setcookie("rememberToken", '');
 }