コード例 #1
0
ファイル: UserTest.php プロジェクト: ameliefranco/casebox
 public function testUpdate()
 {
     $id = DM\User::toId($this->testName);
     $params = array('id' => $id, 'first_name' => '123', 'last_name' => '231', 'sex' => 'f', 'email' => 'f', 'password' => 'a', 'photo' => '/tmp/q.jpg', 'language_id' => 2, 'data' => '{}', 'cfg' => '{"db_user": "******"}', 'recover_hash' => '---', 'enabled' => 0, 'cid' => 1);
     DM\User::update($params);
     $data = DM\User::read($id);
     $params['password'] = md5('aero' . $params['password']);
     $this->assertArraySubset($params, $data);
     //updateByName
     unset($params['id']);
     $params['name'] = $this->testName;
     $params['password'] = '******';
     $params['enabled'] = 1;
     DM\User::updateByName($params);
     $data = DM\User::read($id);
     $params['password'] = md5('aero' . $params['password']);
     $this->assertArraySubset($params, $data);
     //verify password
     $this->assertTrue(DM\User::verifyPassword($id, 'b'), 'Wrong password');
     //check id by mail
     $id = DM\User::getIdByEmail('f');
     $this->assertTrue(is_numeric($id), 'Cant get Id by mail');
     //check id by recover hash
     $id = DM\User::getIdByRecoveryHash('---');
     $this->assertTrue(is_numeric($id), 'Cant get Id by recover hash');
     //check owner
     $this->assertTrue(DM\User::getOwnerId($id) == 1, 'different owner set');
 }
コード例 #2
0
ファイル: Security.php プロジェクト: ameliefranco/casebox
 /**
  * Check if current loged user is owner for given user id
  *
  * @param  int     $userId
  * @return boolean
  */
 public static function isUsersOwner($userId)
 {
     return User::getId() == DM\User::getOwnerId($userId);
 }