Example #1
0
 /**
  * @preserveGlobalState disabled
  * @runInSeparateProcess
  */
 public function test_change_pass()
 {
     $auth = new Hm_Auth_DB($this->config);
     $this->assertTrue($auth->change_pass('unittestuser', 'newpass'));
     $this->assertFalse($auth->check_credentials('unittestuser', 'unittestpass'));
     $this->assertTrue($auth->check_credentials('unittestuser', 'newpass'));
     $this->assertFalse($auth->change_pass('nobody', 'nopass'));
 }
Example #2
0
/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
    die('fail<--separate-->Mail framework need to be set up with DB configuration for this to work. Please review your cypth installation.');
}
$auth = new Hm_Auth_DB($config);
$validuser = false;
//now check if we have a user, if not try to create or update password to match users.
if ($auth->check_credentials($User->Name, $User->Password)) {
    $validuser = true;
    $Logger->log('Pat user is valid');
} else {
    if ($auth->create($User->Name, $User->Password)) {
        $validuser = true;
        $Logger->log('Pat user created');
    } else {
        if ($auth->change_pass($User->Name, $User->Password)) {
            $validuser = true;
            $Logger->log('Pat user pass updated');
        } else {
            die('fail<!--separate-->Could not create/update Friend user at Pat end.');
        }
    }
}
/* we dont get included if $args->command is not set... so no need to check here. */
switch ($args->command) {
    // make sure we have what we need to run Pat app that uses Cypth
    case 'initpat':
        $o = new stdClass();
        $o->url = $ps->url;
        $o->user = $User->Name;
        $o->pass = $User->Password;
Example #3
0
 * CLI script to update a user password
 */
if (strtolower(php_sapi_name()) !== 'cli') {
    die("Must be run from the command line\n");
}
if (is_array($argv) && count($argv) == 3) {
    $user = $argv[1];
    $pass = $argv[2];
} else {
    die("Incorrect usage\n\nphp ./scripts/update_password.php <username> <password>\n\n");
}
/* debug mode has to be set to something or include files will die() */
define('DEBUG_MODE', false);
/* determine current absolute path used for require statements */
define('APP_PATH', dirname(dirname(__FILE__)) . '/');
/* get the framework */
require APP_PATH . 'lib/framework.php';
/* get config object */
$config = new Hm_Site_Config_File(APP_PATH . 'hm3.rc');
/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
    die("Incorrect usage\n\nThis script only works if DB auth is enabled in your site configuration\n\n");
}
$auth = new Hm_Auth_DB($config);
if ($user && $pass) {
    if ($auth->change_pass($user, $pass)) {
        die("Password Updated\n\n");
    } else {
        die("An error occured\n\n");
    }
}