Example #1
0
 public function verifyAction($code)
 {
     try {
         $pe = new \Sayvot\Misc\ParametersEncoder();
         $parameters = $pe->decodeLink("account/verify", $code);
         $account = Account::findFirstByIdAccount($parameters[0]);
         if (!$account) {
             throw new \InvalidArgumentException('No existe una cuenta con el id ingresado');
         }
         $user = User::findFirstByIdUser($parameters[1]);
         if (!$user) {
             throw new \InvalidArgumentException('No existe un usuario con el id ingresado');
         }
         if ($user->idAccount != $account->idAccount) {
             throw new \InvalidArgumentException('No existe un usuario con el id ingresado');
         }
         if ($account->accountplan->price + 0 != 0) {
             return $this->response->redirect("account/paymentdata/{$account->idAccount}");
         }
         $account->confirm = 1;
         if ($account->save()) {
             return $this->response->redirect("session/login");
         }
     } catch (InvalidArgumentException $ex) {
         $this->flashSession->error($ex->getMessage());
         return $this->response->redirect("error");
     } catch (Exception $ex) {
         $this->logger->log("Exception while verify account: {$ex->getMessage()}");
         $this->logger->log($ex->getTraceAsString());
         $this->flashSession->error($ex->getMessage());
         return $this->response->redirect("error");
     }
 }