Example #1
0
 /**
  * @preserveGlobalState disabled
  * @runInSeparateProcess
  */
 public function test_delete()
 {
     $auth = new Hm_Auth_DB($this->config);
     $this->assertTrue($auth->delete('unittestuser'));
     $this->assertFalse($auth->delete('nobody'));
     $config = new Hm_Mock_Config();
     $auth = new Hm_Auth_DB($config);
     $this->assertFalse($auth->delete('unittestuser'));
     $auth = new Hm_Auth_DB($this->config);
     $this->assertTrue($auth->create('unittestuser', 'unittestpass'));
 }
Example #2
0
/* 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.');
        }
    }
}
/* 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':
Example #3
0
 * CLI script to add a user account to the local DB
 */
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/create_account.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->create($user, $pass)) {
        die("User created\n\n");
    } else {
        die("An error occured\n\n");
    }
}