Skip to content

Commit

Permalink
Do not allow passwords to be expired for non-local users
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jul 10, 2018
1 parent b43e4ae commit f9e01b8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/Command/ExpirePassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ protected function configure() {
protected function execute(InputInterface $input, OutputInterface $output) {
$uid = $input->getArgument('uid');

$exists = $this->userManager->userExists($uid);
if($exists === false) {
/** @var $user \OCP\IUser */
$user = $this->userManager->get($uid);

if ($user === null) {
$output->writeln("<error>Unknown user: $uid</error>");
/**
* return EX_NOUSER from /usr/include/sysexits.h
Expand All @@ -88,6 +90,11 @@ protected function execute(InputInterface $input, OutputInterface $output) {
return 67;
}

if (!$user->canChangePassword()) {
$output->writeln("<error>Passwords cannot be expired for user: $uid</error>");
return 1;
}

$date = new \DateTime($input->getArgument('expiredate'));
$date->setTimezone(new \DateTimeZone('UTC'));
$value = $date->format('Y-m-d\TH:i:s\Z'); // ISO8601 with Zulu = UTC
Expand Down

0 comments on commit f9e01b8

Please sign in to comment.