start creating admin password recovery

This commit is contained in:
Manuel Raynaud
2013-10-30 15:01:18 +01:00
parent c327b20fd6
commit 66c30a1b4c
4 changed files with 79 additions and 5 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)
);
}
}