/**
  * Handle form request.
  *
  * @param \Symfony\Component\Form\FormInterface     $form
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return bool
  */
 public function handle(FormInterface $form, Request $request, User $user)
 {
     $this->logger->info('UserChangePasswordHandler= handle()');
     if (!$request->isMethod('POST')) {
         return false;
     }
     $form->handleRequest($request);
     if (!$form->isValid()) {
         $this->flashManager->getErrorMessage();
         return false;
     }
     $userChangePassword = $form->getData();
     $user->setPassword($userChangePassword->getNewPassword());
     $this->userManager->resetPassword($user);
     $this->flashManager->getSuccessMessage('Your password was changed successfully!');
     return true;
 }
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  * @return void
  */
 function load(ObjectManager $manager)
 {
     $userManager = $this->container->get('user.manager');
     $ronald = new User();
     $ronald->setFirstName("Mfana");
     $ronald->setLastName("Conco");
     $ronald->setEmail("*****@*****.**");
     $ronald->setPassword($this->encodePassword($ronald, '654321'));
     $ronald->setStatus($this->getReference("status-active"));
     $ronald->setTitle($this->getReference("title-mr"));
     $ronald->setGender($this->getReference("gender-male"));
     $ronald->setGroup($this->getReference("group-super-admin"));
     $userManager->create($ronald);
     $sammy = new User();
     $sammy->setFirstName("Brian");
     $sammy->setLastName("Sebe");
     $sammy->setEmail("bsebe@prasa.com ");
     $sammy->setPassword($this->encodePassword($sammy, '654321'));
     $sammy->setStatus($this->getReference("status-active"));
     $sammy->setTitle($this->getReference("title-mr"));
     $sammy->setGender($this->getReference("gender-male"));
     $sammy->setGroup($this->getReference("group-super-admin"));
     $userManager->create($sammy);
     $ben = new User();
     $ben->setFirstName("Sekhuthe");
     $ben->setLastName("Makole");
     $ben->setEmail("*****@*****.**");
     $ben->setPassword($this->encodePassword($ben, '654321'));
     $ben->setStatus($this->getReference("status-active"));
     $ben->setTitle($this->getReference("title-mr"));
     $ben->setGender($this->getReference("gender-male"));
     $ben->setGroup($this->getReference("group-super-admin"));
     $userManager->create($ben);
     $this->addReference('admin-ronald', $ronald);
 }
 /**
  * @param Request $request
  * @param User    $user
  * @ParamConverter("artist", class="MlankaTechAppBundle:User", options={"slug" = "slug"})
  * @Secure(roles="ROLE_USER_EDIT")
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function changePasswordAction(Request $request, User $user)
 {
     $this->get('logger')->info('UserController changePasswordAction()');
     if ($this->getUser()->getId() != $user->getId()) {
         $flashManager = $this->get('flash.message.manager');
         $flashManager->getWarningMessage('An illegal action was performed and the system has logged it.');
         return $this->redirect($this->generateUrl('mlanka_tech_app.user_profile', array('slug' => $this->getUser()->getSlug())) . '.html');
     }
     $form = $this->createForm("UserChangePasswordType", new UserChangePassword());
     $formHandler = $this->get('mlanka_tech_app.user_change_password_handler');
     if ($formHandler->handle($form, $request, $user)) {
         return $this->redirect($this->generateUrl('mlanka_tech_app.user_profile', array('slug' => $user->getSlug())));
     }
     return $this->render('MlankaTechAppBundle:User:change.password.html.twig', array('user' => $user, 'form' => $form->createView(), 'action' => 'user_change_password', 'page_header' => 'Change password', 'breadcrumb' => 'Change password'));
 }
 /**
  * Activate operator account.
  *
  * @param \MlankaTech\AppBundle\Entity\User $user
  * @return \MlankaTech\AppBundle\Entity\User
  */
 public function activate(\MlankaTech\AppBundle\Entity\User $user)
 {
     $this->logger->info('Service UserManager activate()');
     $user->setStatus($this->sm->active());
     $user->setActive(true);
     $user->setActivatedAt(new \DateTime());
     $user->setActivatedBy($this->getCurrentUser());
     $user->setLocked(false);
     $this->em->persist($user);
     $this->em->flush();
     return $user;
 }
 /**
  * Build email template.
  *
  * @param User $user
  *
  * @return array
  */
 private function buildTemplate(User $user)
 {
     $this->logger->info('OnUserForgotPasswordListener buildTemplate()');
     $email = array();
     $email['subject'] = 'Reset password link on ' . $this->siteName;
     $email['fullName'] = $user->getFullName();
     $email['password'] = $user->getTransient();
     $email['username'] = $user->getEmail();
     $email['emailAddress'] = $user->getEmail();
     $email['authString'] = $user->getForgotPassword();
     $email['bodyHTML'] = $this->templating->render('MlankaTechAppBundle:Email/Html/User:forgot_password_reset.html.twig', $email);
     $email['bodyTEXT'] = $this->templating->render('MlankaTechAppBundle:Email/Text/User:new_account_created.txt.twig', $email);
     return $email;
 }