Skip to content

Instantly share code, notes, and snippets.

@pellaeon
Created November 28, 2013 12:46
Show Gist options
  • Save pellaeon/7691325 to your computer and use it in GitHub Desktop.
Save pellaeon/7691325 to your computer and use it in GitHub Desktop.
namespace OC\Core\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Auth extends Command {
protected function configure() {
$this
->setName('auth')
->setDescription('Check credentials in CLI')
->addArgument('username', InputArgument::REQUIRED, 'Username')
->addArgument('password', InputArgument::REQUIRED, 'Password')
;
}
protected function execute(InputInterface $input, OutputInterface $output) {
$uid = \OC_User::checkPassword($input->getArgument('username'), $input->getArgument('password'));
if ( $uid == false ) {
echo "auth_ok:-1\n";
} else {
echo "auth_ok:1\n";
echo "dir:".\OC_User::getHome($uid)."\n";
$quota = \OC_Util::getUserQuota($uid);
if ( $quota != \OC\Files\SPACE_UNLIMITED ) {
echo "user_quota_size:".$quota."\n";
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment