Differential D20659 Diff 49281 src/applications/auth/xaction/PhabricatorAuthConfigAutoLoginTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/xaction/PhabricatorAuthConfigAutoLoginTransaction.php
- This file was added.
<?php | |||||
final class PhabricatorAuthConfigAutoLoginTransaction | |||||
extends PhabricatorAuthConfigTransactionType { | |||||
const TRANSACTIONTYPE = 'config:autoLogin'; | |||||
public function generateOldValue($object) { | |||||
return (int)$object->getShouldAutoLogin(); | |||||
} | |||||
public function applyInternalEffects($object, $value) { | |||||
$object->setShouldAutoLogin($value); | |||||
} | |||||
public function getTitle() { | |||||
if ($this->getNewValue()) { | |||||
return pht('%s enabled auto login.', | |||||
$this->renderAuthor()); | |||||
} else { | |||||
return pht('%s disabled auto login.', | |||||
$this->renderAuthor()); | |||||
} | |||||
} | |||||
public function validateTransactions($object, array $xactions) { | |||||
$errors = array(); | |||||
$provider = $object->getProvider(); | |||||
foreach ($xactions as $xaction) { | |||||
if (!$provider->supportsAutoLogin()) { | |||||
$errors[] = $this->newInvalidError( | |||||
pht( | |||||
'Authentication provider "%s" does not support auto login.', | |||||
get_class($provider)), | |||||
$xaction); | |||||
continue; | |||||
} | |||||
} | |||||
return $errors; | |||||
} | |||||
} |