start creating admin password recovery

This commit is contained in:
Manuel Raynaud
2013-10-30 15:01:18 +01:00
parent 9d011eb5c6
commit b0f3ad69d2
5 changed files with 80 additions and 6 deletions

View File

@@ -25,6 +25,7 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Administrator\AdministratorEvent;
use Thelia\Core\Event\Administrator\AdministratorUpdatePasswordEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Admin as AdminModel;
use Thelia\Model\AdminQuery;
@@ -92,15 +93,24 @@ class Administrator extends BaseAction implements EventSubscriberInterface
}
}
public function updatePassword(AdministratorUpdatePasswordEvent $event)
{
if (null !== $admin = AdminQuery::create()->filterByLogin($event->getLogin())->findOne()) {
$admin->setPassword($event->getPassword())
->save();
}
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::ADMINISTRATOR_CREATE => array("create", 128),
TheliaEvents::ADMINISTRATOR_UPDATE => array("update", 128),
TheliaEvents::ADMINISTRATOR_DELETE => array("delete", 128),
TheliaEvents::ADMINISTRATOR_CREATE => array('create', 128),
TheliaEvents::ADMINISTRATOR_UPDATE => array('update', 128),
TheliaEvents::ADMINISTRATOR_DELETE => array('delete', 128),
TheliaEvents::ADMINISTRATOR_UPDATEPASSWORD => array('updatePassword', 128)
);
}
}

View File

@@ -0,0 +1,63 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
/**
* command line for updating admin password
*
* php Thelia admin:updatePassword
*
* Class AdminUpdatePassword
* @package Thelia\Command
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class AdminUpdatePassword extends ContainerAwareCommand
{
/**
* Configures the current command.
*/
protected function configure()
{
$this
->setName('admin:updatePassword')
->setDescription('change administrator password')
->setHelp('The <info>admin:updatePassword</info> command allows you to change the password for a given administrator')
->addArgument(
'login',
InputArgument::REQUIRED,
'Login for administrator you want to change the password'
)
->addOption(
'password',
null,
InputOption::VALUE_REQUIRED,
'Desired password. If this option is omitted, a random password is generated and shown in this prompt after'
)
;
}
}

View File

@@ -39,8 +39,8 @@ class CreateAdminUser extends ContainerAwareCommand
{
$this
->setName("admin:create")
->setDescription("Create a new adminsitration user")
->setHelp("The <info>thelia:create-admin</info> command create a new administration user.")
->setDescription("Create a new administrator user")
->setHelp("The <info>admin:create</info> command create a new administration user.")
->addOption(
'login_name',
null,

View File

@@ -80,5 +80,5 @@ class AdministratorUpdatePasswordEvent extends ActionEvent
return $this->login;
}
}

View File

@@ -565,6 +565,7 @@ final class TheliaEvents
const ADMINISTRATOR_CREATE = "action.createAdministrator";
const ADMINISTRATOR_UPDATE = "action.updateAdministrator";
const ADMINISTRATOR_DELETE = "action.deleteAdministrator";
const ADMINISTRATOR_UPDATEPASSWORD = 'action.generatePassword';
// -- Mailing System management ---------------------------------------------