Skip to content

Instantly share code, notes, and snippets.

@bantu
Forked from pellaeon/auth.php
Created November 28, 2013 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bantu/7692281 to your computer and use it in GitHub Desktop.
Save bantu/7692281 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);
new \OC\Files\Filesystem;
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