* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Changes the password of a user. * * @package symfony * @subpackage task * @author Fabien Potencier * @version SVN: $Id: sfGuardCreateUserTask.class.php 13761 2008-12-05 10:14:51Z fabien $ */ class sfGuardChangePasswordTask extends sfPropelBaseTask { /** * @see sfTask */ protected function configure() { $this->addArguments(array( new sfCommandArgument('username', sfCommandArgument::REQUIRED, 'The user name'), new sfCommandArgument('password', sfCommandArgument::REQUIRED, 'The password'), )); $this->addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', null), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), )); $this->namespace = 'guard'; $this->name = 'change-password'; $this->briefDescription = 'Changes the password of a user'; $this->detailedDescription = <<configuration); $user = sfGuardUserPeer::retrieveByUsername($arguments['username']); if (!$user) { throw new sfCommandException(sprintf('User "%s" does not exist.', $arguments['username'])); } $user->setPassword($arguments['password']); $user->save(); $this->logSection('guard', sprintf('Password changed successfully for user %s', $arguments['username'])); } }