public function testCallApiOperationWithGrants() { TestsHelper::dbFixture(\UserAccount::getTableName(), array(array('login' => 'test', 'password' => passwordColumn::hash('testtest')))); $user = \UserAccount::getById(1); \ACL::create(TestApiWithACLOperation::RightName); \ACL::grant(TestApiWithACLOperation::RightName, $user->obj_rights->getEntity()); \UsersLogin::login('test', 'testtest'); $method = new TestApiWithACLOperation(); $this->assertTrue($method->exec()); }
public static function setupUsers($data) { self::dbFixture(\UserAccount::getTableName(), array()); foreach ($data as $key => $userRow) { $userRights = null; if (!isset($userRow['password'])) { $userRow['password'] = self::DefaultPassword; } self::checkUserRow($userRow); if (isset($userRow['rights'])) { $userRights = $userRow['rights']; } $userRow['password'] = Password::hash($userRow['password']); $user = new \UserAccount($userRow); $user->insert(); if (!empty($userRights)) { $user->rights = $userRights; $user->update(); } } }
public function update($group, $permissions) { if (empty($group)) { $this->AddAlert('Группа пользователей не выбрана'); $this->jump('./'); } set_time_limit(0); $page = 0; $groupInfo = DBSimple::get(ACL_TABLE, ['name' => $group]); if (empty($groupInfo)) { throw new \InvalidArgumentException(sprintf('Group "%s" not found, failed to update group permissions', htmlspecialchars($group))); } $permissions = $this->filterPermissionsByGroup($group, $permissions); do { // получаем пользователей $sql = <<<SQL \tselect u.* from %s as u \tinner join %s as r \ton r.entity = concat("%s", u.id) \twhere r.actionId = "%s" \torder by id asc \tlimit %d,%d SQL; $sql = sprintf($sql, \UserAccount::getTableName(), \ACL_GRANT_TABLE, \Faid\DB::escape(\UserAccount::ModelName), $groupInfo['id'], $page * self::Limit, self::Limit); $data = DB::query($sql); // устанавливаем каждому права foreach ($data as $row) { $user = new \UserAccount($row); $tmp = $user->rights->getValue(); $tmp = array_merge($tmp, $permissions); $user->rights = $tmp; $user->update(); } $page++; } while (sizeof($data) != 0); $this->addAlert('Права обновлены'); $this->jump('./'); }
/** * @expectedException \Extasy\Users\login\UserNotConfirmedException */ public function testUserNotConfirmed() { DBSimple::update(\UserAccount::getTableName(), ['confirmation_code' => 'some_value'], ['id' => 1]); $api = new Login(); $api->exec(); }
public static function findByEmail($email) { $result = DBSimple::get(UserAccount::getTableName(), array(sprintf('`email` = "%s" ', DB::escape($email), DB::escape($email)))); return $result; }
<?php use Faid\Configure\Configure; use Extasy\CMS; \Extasy\tests\ErrorHandlers::setUp(); \Faid\Debug\Debug::enable(); Configure::write(CMS::SaltConfigureKey, 'extasySalt'); Configure::write(\Extasy\Schedule\Runner::TimeoutConfigureKey, 30); Configure::write(CMS::DashboardConfigureKey, array('url' => '/', 'Domain' => 'extasy')); Configure::write(CMS::MainDomainConfigureKey, 'extasy'); // Собственно, имя проекта define('SITE_NAME', 'Extasy Framework'); // Путь до закачиваемых пользователем файлов define('FILE_PATH', EXTASY_PATH . 'tests/data/'); Configure::write(\Extasy\CMS::FileConfigureKey, EXTASY_PATH . 'tests/data/'); Configure::write(\Extasy\CMS::FilesHttpRoot, '/tests/data/'); Configure::write('UParser.tmp_dir', FILE_PATH); Configure::write('Sitemap', ['Menu' => ['title' => 'Меню сайта', 'depth' => 2]]); Configure::write(\UserAccount::ModelConfigureKey, ['table' => UserAccount::getTableName(), 'api' => ['profileUpdateFields' => 'name,surname'], 'fields' => ['id' => '\\Extasy\\Columns\\Index', 'login' => '\\Extasy\\Users\\Columns\\Login', 'password' => '\\Extasy\\Columns\\Password', 'rights' => '\\GrantColumn', 'time_access' => '\\Extasy\\Users\\Columns\\TimeAccess', 'registered' => '\\Extasy\\Columns\\Datetime', 'last_activity_date' => '\\Extasy\\Columns\\Datetime', 'confirmation_code' => '\\Extasy\\Users\\Columns\\ConfirmationCode', 'email_confirmation_code' => '\\Extasy\\Columns\\Input', 'email' => '\\Extasy\\Users\\Columns\\Email', 'new_email' => '\\Extasy\\Columns\\Input', 'name' => '\\Extasy\\Columns\\Input', 'surname' => '\\Extasy\\Columns\\Input', 'social_networks' => ['class' => '\\Extasy\\Users\\Columns\\SocialNetworks', 'parse_field' => 1], 'avatar' => ['class' => '\\Extasy\\Columns\\Image', 'base_dir' => 'users/', 'images' => '']]]); // Режим отладки define('DEBUG', 1); $db = array('host' => 'localhost', 'user' => 'extasy', 'password' => '', 'database' => 'extasy'); $cacheConfig = array('Engine' => '\\Faid\\Cache\\Engine\\FileCache', 'FileCache' => array('BaseDir' => EXTASY_PATH . 'tests/data/')); Configure::write('DB', $db); Configure::write('SimpleCache', $cacheConfig);