public function changePasswordAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); $login = $request->getParam('login'); $password = $request->getParam('password'); if (is_null($password) || !is_string($password) || $password == '') { $this->getResponse()->setHttpResponseCode(400); $this->getResponse()->setBody("ERROR: Empty password given."); return; } $account = Opus_Account::fetchAccountByLogin($login); if (is_null($account)) { $this->getResponse()->setHttpResponseCode(400); $this->getResponse()->setBody("ERROR: Account '{$login}' does not exist."); return; } try { $account->setPassword($password); $account->store(); } catch (Opus_Security_Exception $e) { $this->getResponse()->setHttpResponseCode(400); $this->getResponse()->setBody("ERROR: " . $e->getMessage()); return; } $this->getResponse()->setBody('SUCCESS'); }
public function tearDown() { $this->logoutUser(); $this->restoreSecuritySetting(); $user = Opus_Account::fetchAccountByLogin($this->userName); $user->delete(); $userRole = Opus_UserRole::fetchByName($this->roleName); $userRole->delete(); parent::tearDown(); }
public function __construct() { $this->_log = Zend_Registry::get("Zend_Log"); $login = Zend_Auth::getInstance()->getIdentity(); if (is_null($login) or trim($login) == '') { return; } $account = Opus_Account::fetchAccountByLogin($login); if (is_null($account) or $account->isNewRecord()) { $this->_log->err("Error checking logged user: Invalid account returned for user '{$login}'!"); return; } $this->_login = $login; $this->_account = $account; }
public function getRecipients($users = null) { if (!is_array($users)) { $users = array($users); } $allRecipients = array(); foreach ($users as $user) { $account = Opus_Account::fetchAccountByLogin($user); if (is_null($account)) { $this->_logger->warn(__CLASS__ . ": User '{$user}' does not exist... skipping mail."); continue; } $mail = $account->getEmail(); if (is_null($mail) or trim($mail) == '') { $this->_logger->warn(__CLASS__ . ": No mail address for user '{$user}'... skipping mail."); continue; } $allRecipients[] = array('name' => $account->getFirstName() . ' ' . $account->getLastName(), 'address' => $mail); } return $allRecipients; }
/** * Simple test action to check "add" module. */ public function testChangePasswordAction() { $this->addTestAccountWithRoles(); // Test if changing password works... $password = "******" . rand(); $requestData = array('login' => $this->login, 'password' => $password); /* Creating first collection to work with. */ $this->request->setMethod('POST')->setPost($requestData); $this->dispatch('/remotecontrol/account/change-password'); // Make sure, this request returned successfully. $this->assertResponseCode(200); $this->assertController('account'); $this->assertAction('change-password'); $body = $this->getResponse()->getBody(); $this->checkForBadStringsInHtml($body); $this->assertContains('SUCCESS', $body); // Test if created account really exists... $account = Opus_Account::fetchAccountByLogin($this->login); $this->assertTrue($account instanceof Opus_Account); $this->assertEquals($this->login, $account->getLogin()); $this->assertTrue($account->isPasswordCorrect($password)); $this->assertFalse($account->isPasswordCorrect($this->password)); }
/** * Test changing login. */ public function testChangeLoginSuccess() { $config = Zend_Registry::get('Zend_Config'); $config->account->editOwnAccount = 1; $this->deleteUser('john2'); $this->loginUser('john', 'testpwd'); $this->getRequest()->setMethod('POST')->setPost(array('username' => 'john2', 'firstname' => '', 'lastname' => '', 'email' => '')); $this->dispatch('/account/index/save'); $this->assertRedirect(); // Check if new user exists (with proper password) and old does not... $account = Opus_Account::fetchAccountByLogin('john2'); $this->assertNotNull($account); $this->assertTrue($account->isPasswordCorrect('testpwd')); $account = Opus_Account::fetchAccountByLogin('john'); $this->assertNull($account); // Delete user 'john2' if we're done... $this->deleteUser('john2'); }