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
// this file is included in module.php in the folder above...
global $User, $SqlDatabase, $args, $Logger;
// STEP 1: check that we have valid settings for pat app
$ps = getPatSettings();
/* CYPHT stuff..... */
define('APP_PATH', $ps->fileroot . (substr($ps->fileroot, -1) == '/' ? '' : '/'));
require APP_PATH . 'lib/framework.php';
$config = new Hm_Site_Config_File(APP_PATH . 'hm3.rc');
/* 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.');
        }
    }
}