start creating admin password recovery
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Thelia\Action;
|
|||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Core\Event\Administrator\AdministratorEvent;
|
use Thelia\Core\Event\Administrator\AdministratorEvent;
|
||||||
|
use Thelia\Core\Event\Administrator\AdministratorUpdatePasswordEvent;
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
use Thelia\Model\Admin as AdminModel;
|
use Thelia\Model\Admin as AdminModel;
|
||||||
use Thelia\Model\AdminQuery;
|
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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
TheliaEvents::ADMINISTRATOR_CREATE => array("create", 128),
|
TheliaEvents::ADMINISTRATOR_CREATE => array('create', 128),
|
||||||
TheliaEvents::ADMINISTRATOR_UPDATE => array("update", 128),
|
TheliaEvents::ADMINISTRATOR_UPDATE => array('update', 128),
|
||||||
TheliaEvents::ADMINISTRATOR_DELETE => array("delete", 128),
|
TheliaEvents::ADMINISTRATOR_DELETE => array('delete', 128),
|
||||||
|
TheliaEvents::ADMINISTRATOR_UPDATEPASSWORD => array('updatePassword', 128)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
63
core/lib/Thelia/Command/AdminUpdatePassword.php
Normal file
63
core/lib/Thelia/Command/AdminUpdatePassword.php
Normal 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'
|
||||||
|
)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,8 +39,8 @@ class CreateAdminUser extends ContainerAwareCommand
|
|||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName("admin:create")
|
->setName("admin:create")
|
||||||
->setDescription("Create a new adminsitration user")
|
->setDescription("Create a new administrator user")
|
||||||
->setHelp("The <info>thelia:create-admin</info> command create a new administration user.")
|
->setHelp("The <info>admin:create</info> command create a new administration user.")
|
||||||
->addOption(
|
->addOption(
|
||||||
'login_name',
|
'login_name',
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -565,6 +565,7 @@ final class TheliaEvents
|
|||||||
const ADMINISTRATOR_CREATE = "action.createAdministrator";
|
const ADMINISTRATOR_CREATE = "action.createAdministrator";
|
||||||
const ADMINISTRATOR_UPDATE = "action.updateAdministrator";
|
const ADMINISTRATOR_UPDATE = "action.updateAdministrator";
|
||||||
const ADMINISTRATOR_DELETE = "action.deleteAdministrator";
|
const ADMINISTRATOR_DELETE = "action.deleteAdministrator";
|
||||||
|
const ADMINISTRATOR_UPDATEPASSWORD = 'action.generatePassword';
|
||||||
|
|
||||||
// -- Mailing System management ---------------------------------------------
|
// -- Mailing System management ---------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user