/** * (non-PHPdoc) * @see lib/Faett/Core/Interfaces/Faett_Core_Interfaces_Service#setPassword() */ public function setPassword($password, $channel, $layer = 'user') { // set password for channel $this->_config->set('password', $password, $layer, $channel); // write config $this->_config->store($layer); }
/** * Execute the 'login' command. * * @param string $command command name * * @param array $options option_name => value * * @param array $params list of additional parameters * * @return bool TRUE on success or * a PEAR error on failure * * @access public */ function doLogin($command, $options, $params) { $reg =& $this->config->getRegistry(); // If a parameter is supplied, use that as the channel to log in to if (isset($params[0])) { $channel = $params[0]; } else { $channel = $this->config->get('default_channel'); } $chan = $reg->getChannel($channel); if (PEAR::isError($chan)) { return $this->raiseError($chan); } $server = $this->config->get('preferred_mirror', null, $channel); $remote =& $this->config->getRemote(); $username = $this->config->get('username', null, $channel); if (empty($username)) { $username = isset($_ENV['USER']) ? $_ENV['USER'] : null; } $this->ui->outputData("Logging in to {$server}.", $command); list($username, $password) = $this->ui->userDialog($command, array('Username', 'Password'), array('text', 'password'), array($username, '')); $username = trim($username); $password = trim($password); $ourfile = $this->config->getConfFile('user'); if (!$ourfile) { $ourfile = $this->config->getConfFile('system'); } $this->config->set('username', $username, 'user', $channel); $this->config->set('password', $password, 'user', $channel); if ($chan->supportsREST()) { $ok = true; } else { $remote->expectError(401); $ok = $remote->call('logintest'); $remote->popExpect(); } if ($ok === true) { $this->ui->outputData("Logged in.", $command); // avoid changing any temporary settings changed with -d $ourconfig = new PEAR_Config($ourfile, $ourfile); $ourconfig->set('username', $username, 'user', $channel); $ourconfig->set('password', $password, 'user', $channel); $ourconfig->store(); } else { return $this->raiseError("Login failed!"); } return true; }