protected function factoryColumn($userLogin) { $user = \UserAccount::getByLogin($userLogin); $this->column = new SocialNetworks('testName', [], null); $this->column->setDocument($user); return $this->column; }
public function setup() { parent::setUp(); \ACL::create(\CMSAuth::AdministratorRoleName); Helper::setupUsers(array(array('login' => self::login, 'password' => self::password, 'rights' => array(\CMSAuth::AdministratorRoleName => true)))); $user = \UserAccount::getByLogin(self::login); \ACL::grant(\CMSAuth::AdministratorRoleName, $user->rights->getEntity()); }
/** * @expectedException \ForbiddenException */ public function testAllRightsChecked() { $user = \UserAccount::getByLogin(self::loginFixture); Acl::grant(self::testReadRight, $user->obj_rights->getEntity()); UsersLogin::login(self::loginFixture, self::passwordFixture); // $controller = new TestController(); $controller->setRequiredRights(array(self::testReadRight, self::testWriteRight)); $controller->process(); }
public function testRegistration() { $schema = \CConfig::getSchema(\UsersRegistration::RegistrationConfirmationConfigName); $api = new Registration($this->correctForm); $api->exec(); $this->assertTrue($this->mailer->isSent()); $lastEmail = \EmailLogModel::getLast(); $this->assertEquals($lastEmail->to->getValue(), self::SomeCorrectEmail); $user = \UserAccount::getByLogin(self::NewLogin); $this->assertEquals($user->social_networks->getValue()['facebook'], self::NewUID); }
public function setUp() { parent::setUp(); Helper::dbFixture(Job::TableName, array()); $this->setRunnerTimeout(0); Restorator::restore(); Helper::setupUsers([['login' => self::Login, 'password' => self::Password], ['login' => 'guest', 'password' => self::Password]]); $user = \UserAccount::getByLogin(self::Login); \ACL::create(\CMSAuth::SystemAdministratorRoleName); \ACL::grant(\CMSAuth::SystemAdministratorRoleName, $user->rights->getEntity()); \UsersLogin::forceLogin($user); TestAction::setUp(); }
protected static function loadGuestUserRights() { try { $actual = SimpleCache::isActual(self::CacheKey); } catch (SimpleCacheException $e) { $actual = false; } if (!$actual) { try { $user = UserAccount::getByLogin('guest'); $result = self::extractUserGrants($user); } catch (Exception $e) { CMSLog::addMessage('acl', $e); $result = array(); } SimpleCache::set(self::CacheKey, $result, self::CacheLifeTime); } else { $result = SimpleCache::get(self::CacheKey); } return $result; }
public static function login($login, $password, $remember = false) { CMSLog::addMessage(self::LogName, sprintf('Login attempt into "%s"', $login)); try { UsersLogin::testLoginAttempts(); } catch (\Extasy\Users\login\LoginAttemptsException $e) { CMSLog::addMessage(__CLASS__, sprintf('Login attempts limit exceeded')); CMSLog::addMessage(__CLASS__, $e); try { $user = UserAccount::getByLogin($login); $e->blockUser($user); throw $e; } catch (\NotFoundException $e) { } return; } try { $user = UserAccount::getByLogin($login); self::isAuthPassed($user, $password); \Extasy\Users\login\LoginAttempt::quickRegister($user, true); } catch (\Exception $e) { \Extasy\Users\login\LoginAttempt::quickRegister(!empty($user) ? $user : null, false); throw $e; } self::testConfirmationCode($user); $user->updateLastActivityDate(); // write to session login self::setupSession($user->getData(), $remember); // self::$currentUser = $user; // CMSLog::addMessage(self::LogName, sprintf('User identified as "%s"', $login)); // Вызываем обработку события, на вход в каждый перехватчик передается текущий объект пользователя EventController::callEvent('users_after_login', $user); }