public function actionRegistration()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new RegistrationForm();
     if ($model->load($this->post()) && $model->registration()) {
         Yii::$app->user->login($model->getUser(), Yii::$app->params['userLoginTime']);
         return $this->goBack();
     } else {
         return $this->render(['model' => $model]);
     }
 }
 public function formSucceeded(RegistrationForm $form)
 {
     if ($form['remember']->getValue()) {
         $this->user->setExpiration('14 days', false);
     } else {
         $this->user->setExpiration('20 minutes', true);
     }
     $date = DateTime::createFromFormat('Y-m-d', date("Y-m-d"));
     try {
         $this->manager->add($form['username']->getValue(), $form['password']->getValue(), $form['email']->getValue(), $date);
         $this->user->login($form['username']->getValue(), $form['password']->getValue());
     } catch (Nette\Security\AuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }