/**
  * @return mixed
  */
 public function addEmailAction()
 {
     $code = $this->params()->fromRoute('code');
     $codeEntity = $this->userCodes->getCode4Data($code, UserCodes::TYPE_ADD_EMAIL);
     if (!$codeEntity) {
         return $this->forward()->dispatch(AuthController::class, ['action' => 'wrong-code']);
     }
     $user = $this->addEmailService->changeMail($codeEntity->getUser());
     $this->userCodes->deleteCode($codeEntity);
     $this->userService->doAuthentication($user);
     return null;
 }
Exemple #2
0
 /**
  * @param array $data
  * @param UserCodesEntity $userCode
  * @return bool|UserInterface
  */
 public function lostPwConfirm(array $data, UserCodesEntity $userCode)
 {
     $form = $this->passwordForm;
     /** @var \PServerCore\Form\PasswordFilter $filter */
     $filter = $form->getInputFilter();
     if ($this->getEntityManagerAnswer()->getAnswer4UserId($userCode->getUser()->getId())) {
         $filter->addAnswerValidation($userCode->getUser());
     }
     $form->setData($data);
     if (!$form->isValid()) {
         return false;
     }
     $data = $form->getData();
     $plainPassword = $data['password'];
     $userEntity = $userCode->getUser();
     $this->setNewPasswordAtUser($userEntity, $plainPassword);
     $this->userCodeService->deleteCode($userCode);
     if ($this->isSamePasswordOption()) {
         $gameBackend = $this->gameDataService;
         $gameBackend->setUser($userEntity, $plainPassword);
     }
     return $userEntity;
 }