public function testOfControllerGoodTokenMatchedNewPassword()
    {
        $time = strtotime('-1 hour');
        $q = <<<SQL
UPDATE #prefix#owners
SET password_token = '{$this->token}_{$time}'
WHERE id = 1;
SQL;
        $this->db->exec($q);
        $_POST['password'] = '******';
        $_POST['password_confirm'] = 'the same';
        $_GET['token'] = $this->token;
        $controller = new PasswordResetController(true);
        $result = $controller->go();
        $dao = DAOFactory::getDAO('OwnerDAO');
        $session = new Session();
        $this->assertTrue($session->pwdCheck($_POST['password'], $dao->getPass('*****@*****.**')));
    }
    public function testOfControllerGoodTokenMatchedNewPassword() {
        $dao = DAOFactory::getDAO('OwnerDAO');
        $dao->setAccountStatus("*****@*****.**", "Deactivated account");

        $time = strtotime('-1 hour');
        $q = <<<SQL
UPDATE #prefix#owners
SET password_token = '{$this->token}_{$time}'
WHERE id = 1;
SQL;
        $this->testdb_helper->runSQL($q);

        $_POST['password'] = '******';
        $_POST['password_confirm'] = 'the same';
        $_GET['token'] = $this->token;
        $controller = new PasswordResetController(true);
        $result = $controller->go();

        $session = new Session();

        $this->assertTrue($session->pwdCheck($_POST['password'], $dao->getPass('*****@*****.**')));
        $owner = $dao->getByEmail('*****@*****.**');
        $this->assertEqual($owner->account_status, '');
    }
 public function testOfControllerWithRegistrationClosed()
 {
     // make sure registration is closed
     $bvalues = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'is_registration_open', 'option_value' => 'false');
     $bdata = FixtureBuilder::build('options', $bvalues);
     $controller = new PasswordResetController(true);
     $result = $controller->go();
     $v_mgr = $controller->getViewManager();
     $this->assertEqual($v_mgr->getTemplateDataItem('is_registration_open'), false);
     $this->assertNoPattern('/Register/', $result);
 }
예제 #4
0
/**
 *
 * ThinkUp/webapp/session/reset.php
 *
 * Copyright (c) 2009-2016 Gina Trapani, Michael Louis Thaler
 *
 * LICENSE:
 *
 * This file is part of ThinkUp (http://thinkup.com).
 *
 * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
 * later version.
 *
 * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with ThinkUp.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 *
 * @author Michael Louis Thaler <michael[dot]louis[dot]thaler[at]gmail[dot]com>
 * @license http://www.gnu.org/licenses/gpl.html
 * @copyright 2009-2016 Gina Trapani, Michael Louis Thaler
 */
chdir('..');
require_once 'init.php';
$controller = new PasswordResetController();
echo $controller->go();
 public function testOwnerHasCleanStateAfterSuccessfulPasswordReset()
 {
     $builder = FixtureBuilder::build('owners', array('id' => 3, 'full_name' => 'Zaphod Beeblebrox', 'email' => '*****@*****.**', 'is_activated' => false, 'failed_logins' => 10, 'account_status' => 'Deactivated account'));
     $dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $dao->getByEmail('*****@*****.**');
     $token = $owner->setPasswordRecoveryToken();
     $_POST['password'] = '******';
     $_POST['password_confirm'] = 'trillian';
     $_GET['token'] = $token;
     $controller = new PasswordResetController(true);
     $result = $controller->go();
     // Lack of error_msg in PasswordResetController's view template indicates success.
     $v_mgr = $controller->getViewManager();
     $this->assertFalse($v_mgr->getTemplateDataItem('error_msg'));
     $owner = $dao->getByEmail('*****@*****.**');
     $this->assertTrue($owner->is_activated);
     $this->assertEqual($owner->account_status, '');
     $this->assertEqual($owner->failed_logins, 0);
 }