Exemple #1
0
 public static function getCurrentUser()
 {
     if (!UsersLogin::isLogined()) {
         return;
     }
     return array('currentUser' => UsersLogin::getCurrentSession()->getParseData());
 }
Exemple #2
0
 public function testLogin()
 {
     $api = new Login();
     $api->exec();
     $this->assertTrue(\UsersLogin::isLogined());
     $this->assertEquals(\UsersLogin::getCurrentSession()->login->getValue(), self::Login);
 }
Exemple #3
0
 public function check()
 {
     if (!UsersLogin::isLogined()) {
         $this->user = null;
     }
     $needAuth = empty($this->user);
     if ($needAuth) {
         $authDataPresent = !empty($this->login) || !empty($this->password);
         try {
             if ($authDataPresent || UsersLogin::isLogined()) {
                 if ($authDataPresent) {
                     UsersLogin::login($this->login, $this->password);
                 }
             }
             $this->user = UsersLogin::getCurrentUser();
             $this->processUser();
         } catch (ForbiddenException $e) {
             $this->authProc();
             return false;
         } catch (\NotFoundException $e) {
             $this->authProc();
             return false;
         }
     }
     return true;
 }
Exemple #4
0
 public static function getCurrentUserGrants()
 {
     $result = self::loadGuestUserRights();
     //
     if (UsersLogin::isLogined()) {
         $result = array_merge($result, self::extractUserGrants(UsersLogin::getCurrentSession()));
     }
     return $result;
 }
Exemple #5
0
 public function testLogout()
 {
     \UsersLogin::login(self::Login, self::Password);
     $this->AssertTrue(\UsersLogin::isLogined());
     $api = new Logout();
     $api->exec();
     $this->AssertFalse(\UsersLogin::isLogined());
     //
 }
Exemple #6
0
 public function testForInjections()
 {
     if (\UsersLogin::isLogined()) {
         if (\CMSAuth::getInstance()->isAdmin(\UsersLogin::getCurrentSession())) {
             return;
         }
     }
     foreach ($this->data as $key => $value) {
         self::validateParameter($key, $value);
     }
     $this->validateParameter('Current page url', $this->uri());
 }
Exemple #7
0
 public function __construct($urlInfo = array())
 {
     parent::__construct($urlInfo);
     if (!UsersLogin::isLogined()) {
         /**
          * @todo Избавиться от этой зависимости
          */
         $this->addAlert(\plugins\MessageDictionary\Plugin::getMessage('need_auth'));
         $this->jump('/');
         throw new Exception('User not logined');
     }
     $this->aProfile = UsersLogin::getCurrentSession();
 }
Exemple #8
0
 protected function action()
 {
     if (\UsersLogin::isLogined()) {
         \UsersLogin::logout();
     }
 }
Exemple #9
0
 /**
  * (non-PHPdoc)
  * @see Page::main()
  */
 public function main($aData = array(), $error = '')
 {
     if (UsersLogin::isLogined()) {
         $this->jump('/profile/');
     }
     $this->loadMeta();
     $this->aParse['postData'] = $aData;
     $this->aParse['aProfile'] = $aData;
     $this->aParse['signupFailed'] = htmlspecialchars($error);
     if (!empty($this->recaptchaPublicKey)) {
         $this->aParse['captcha'] = recaptcha_get_html($this->recaptchaPublicKey, $error);
     }
     $this->output('users/registration/form');
 }
Exemple #10
0
 public function tearDown()
 {
     if (\UsersLogin::isLogined()) {
         \UsersLogin::logout();
     }
 }