Ejemplo n.º 1
0
 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());
 }
Ejemplo n.º 2
0
 public function resetPassword($userId, $code)
 {
     $user = UserAccount::getById($userId);
     if ($user->password->getValue() == $code) {
         UsersForgot::resetPassword($user);
         $this->addAlert('Пароль выслан');
     } else {
         $this->addAlert('Токен не найден');
     }
     $this->jump('/');
 }
Ejemplo n.º 3
0
 public static function getByUID($uid, $network)
 {
     $network = Network::getByName($network);
     $found = DBSimple::get(self::UIDTable, ['uid' => $uid, 'network_id' => $network->id->getValue()]);
     if (empty($found)) {
         throw new SocialNetworksException('UID not found');
     }
     $user = \UserAccount::getById($found['user_id']);
     return $user;
 }
Ejemplo n.º 4
0
 /**
  *
  * @param unknown $login
  * @param unknown $password
  * @param unknown $email
  *
  * @throws Exception
  */
 public function signup($login, $password, $email)
 {
     try {
         self::testCaptcha(isset($_POST['kcaptcha']) ? $_POST['kcaptcha'] : '');
         $userId = UsersRegistration::signup($login, $password, $email, $_POST);
         $user = \UserAccount::getById($userId);
         $avatar = $this->acceptFile('avatar');
         if (!empty($avatar)) {
             $user->avatar->copyFrom($avatar);
             $user->update();
             if (file_exists($avatar)) {
                 unlink($avatar);
             }
         }
         $this->jump('/signup/?success=1');
     } catch (Exception $e) {
         CMSLog::addMessage('registration', $e);
         $this->main($_POST, $e->getMessage());
     }
 }
Ejemplo n.º 5
0
 /**
  * @return UserAccount
  */
 public static function getCurrentSession()
 {
     if (!empty(self::$currentUser)) {
         return self::$currentUser;
     } elseif (!empty(self::$session)) {
         try {
             self::$currentUser = UserAccount::getById(self::$session['id']);
         } catch (\NotFoundException $e) {
             self::unsetSession();
             throw $e;
         }
         return self::$currentUser;
     }
     return null;
 }