public function registration() { Application::instance()->log('register'); $user = new \models\User('create'); if (!empty($_POST)) { $user->login = $_POST['login']; $user->password = $_POST['password']; $user->password_retype = $_POST['password_retype']; if ($user->validate()) { $user->password = password_hash($user->password, PASSWORD_BCRYPT); unset($user->password_retype); if ($user->save()) { $this->redirect('/user/login'); } } } $this->render('registration', ['user' => $user]); }