public function newPasswordAction() { $hash = $this->params('hash'); $flashMessenger = $this->flashMessenger(); $form = $this->serviceLocator->get('Application\\Form\\NewPassword')->init(); $passwordHashEntity = $this->userService->getPasswordLinkByHash($hash); if ($hash === null) { return $this->notFoundAction(); } if ($passwordHashEntity === null || !$this->userService->checkPasswordLinkLife($passwordHashEntity)) { $flashMessenger->addErrorMessage('DepositoryWeb.selfService.newPassword.noHash'); return $this->notFoundAction(); } if ($this->request->isPost()) { $form->setData($this->request->getPost()); if ($form->isValid()) { $newPassword = $form->getInputFilter()->getValue('password'); $user = $passwordHashEntity->getUser(); $this->userService->changePassword($user, $newPassword); $translator = $this->serviceLocator->get('MvcTranslator'); $container = new Container('passwordChanged'); $container->passwordChanged = $translator->translate('User.NewPassword.passwordChanged'); return $this->redirect()->toRoute('zfcuser/login'); } } $view = new ViewModel(); $view->form = $form; return $view; }
public function getServiceConfig() { return ['factories' => [__NAMESPACE__ . '/Service/' . __NAMESPACE__ . 'Service' => function ($serviceManager) { $service = new Service\UserService(); return $service->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Repository/' . __NAMESPACE__ . 'Repository' => function ($serviceManager) { $repository = new Repository\UserRepository(); return $repository->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Event/' . __NAMESPACE__ . 'Event' => function ($serviceManager) { $event = new Event\UserEvent(); return $event->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Listener/' . __NAMESPACE__ . 'Listener' => function ($serviceManager) { $listener = new Listener\UserListener(); return $listener->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Administrator/Service/AdministratorService' => function ($serviceManager) { $service = new Administrator\Service\AdministratorService(); return $service->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Administrator/Repository/AdministratorRepository' => function ($serviceManager) { $repository = new Administrator\Repository\AdministratorRepository(); return $repository->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Administrator/Event/AdministratorEvent' => function ($serviceManager) { $event = new Administrator\Event\AdministratorEvent(); return $event->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Administrator/Listener/AdministratorListener' => function ($serviceManager) { $listener = new Administrator\Listener\AdministratorListener(); return $listener->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Avatar/Service/AvatarService' => function ($serviceManager) { $service = new Avatar\Service\AvatarService(); return $service->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Avatar/Repository/AvatarRepository' => function ($serviceManager) { $repository = new Avatar\Repository\AvatarRepository(); return $repository->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Avatar/Event/AvatarEvent' => function ($serviceManager) { $event = new Avatar\Event\AvatarEvent(); return $event->setServiceManager($serviceManager); }, __NAMESPACE__ . '/Avatar/Listener/AvatarListener' => function ($serviceManager) { $listener = new Avatar\Listener\AvatarListener(); return $listener->setServiceManager($serviceManager); }]]; }
public function registerAction() { /** @var \User\Form\RegisterForm $form */ $form = $this->getServiceLocator()->get('FormElementManager')->get('User\\Form\\RegisterForm'); $user = new User(); $form->bind($user); if ($this->getRequest()->isPost()) { $form->setData($this->getRequest()->getPost()); if ($form->isValid()) { // @todo: remove this, @see UserService::hashPassword(). $pass = $user->getPassword(); $user->setPassword(UserService::hashPassword($pass)); $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $objectManager->persist($user); $objectManager->flush(); $this->flashMessenger()->addSuccessMessage('Thank you for registration!'); return $this->redirect()->toRoute('home'); } } $model = new ViewModel(array('form' => $form)); $model->setTemplate('basic/form.phtml'); return $model; }
/** * Retrieve roles for the current identity * * @return string[]|\Zend\Permissions\Acl\Role\RoleInterface[] */ public function getIdentityRoles() { return [$this->userService->getCurrentRole()]; }